haxe
haxe copied to clipboard
Bogus constraint check failure in static scope
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
}
}
This is one of those struct unification issues, so I label it for RC and assign to Simon.
regression: no
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.
With #9549 both cases fail in the same way.
... now I just have to understand if that's good or bad.