haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Bogus constraint check failure in static scope

Open ousado opened this issue 8 years ago • 4 comments

In static scope, e.g. when initializing static variables, type parameter constraint checks are inconsistent in Haxe version 3.2.0, in current development the issue doesn't occur, but it should be taken into account when dealing with other TAnon unification issues.

class C<T:{a:Int}>{
    var v:T;
    public function new(v:T) this.v = v;
}

class Issue5214 {

    static var ab:{a:Int,b:String} = {a:1,b:""};
    static var c  = new C(ab);
    static var c1 = new C({a:1,b:""}); // Constraint check failure - characters 20-37 : { b : String, a : Int } has extra field b

    static function main(){
        var c  = new C(ab);
        var c1 = new C({a:1,b:""}); // no such error 
    }
}

ousado avatar May 08 '16 13:05 ousado

This is one of those struct unification issues, so I label it for RC and assign to Simon.

nadako avatar May 19 '16 15:05 nadako

regression: no

ousado avatar May 19 '16 20:05 ousado

The delayed nature of constraints check doesn't play along very well with the TAnon mutability changes. A unification may or may not change a Const anon structure to Closed before a constraints check is made which could then influence unification behavior.

I don't think there's anything we can do about this for the RC and probably not 3.3 final either.

Simn avatar May 23 '16 08:05 Simn

With #9549 both cases fail in the same way.

... now I just have to understand if that's good or bad.

Simn avatar Jun 09 '20 13:06 Simn