New Issue: init= not called with a isTuple() where clause

18219, "ShreyasKhandekar", "init= not called with a isTuple() where clause", "2021-08-13T13:34:05Z"

Currently we allow init= for records where the RHS does not need to be the same type as the Record itself. I was trying to utilize tuples in an init= function and was encountering a situation where it seemed like the function was not being called at all.

Here is a small reproducer of the same issue

A trivial record with two values

record Foo {
    var x: int;
    var y: string;

    proc init(x: int, y: string){
        this.x = x + 1;
        this.y = y + "!";
    }

    proc init=(tup) where isTuple(tup){
        this.init(tup(0), tup(1));
    }

}

I initialized two variables here, one using the init function and one using (in theory) init=

var bar: Foo = new Foo(10, "Hi"); // Should call init
var baz: Foo = (11, "Bye"); // Should call init=

But when I printed these variables and some data associated with them I got the following:

writeln(bar);
writeln(baz); // Quietly changed baz's type from Foo to a normal Tuple?

writeln(isTuple(bar)); // false
writeln(isTuple(baz)); // true ??

outputs:

(x = 11, y = Hi!)
(11, Bye)
false
true

This behavior seems very buggy since the correct function isn't called and the type of a variable is changed from what it was explicitly typed to be with no indication that it happened.