You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typedef A = {
var y : Int;
}
typedef B = {
var x : Int;
}
class Test {
static function foo<V, T : (V, A), U : (V, B)>(x : T) : Void {
}
static function main() {
foo("toto");
}
}
ouputs this error:
Build failure
Test.hx:16: characters 4-7 : Constraint check failure for foo.T
Test.hx:16: characters 4-7 : String should be B
Test.hx:16: characters 4-7 : String should be { x : Int }
Test.hx:16: characters 4-7 : String has no field x
Test.hx:16: characters 4-7 : Constraint check failure for foo.T
Test.hx:16: characters 4-7 : String should be A
Test.hx:16: characters 4-7 : String should be { y : Int }
Test.hx:16: characters 4-7 : String has no field y
Whereas 'String should be A' is correct, 'String should be B' is incorrect.
The text was updated successfully, but these errors were encountered:
Mmmm, thanks for the explanation.
I was thinking that the compiler would infer U as a subtype of both V (string) and B (typedef); a kind of type union.
From your explanation, I understand that no ad'hoc subtype representation exist in the compiler.
Note: that maybe using 'String' for the example is misleading, the non shrinked version was involving only typedefs / anonymous
ouputs this error:
Build failure
Test.hx:16: characters 4-7 : Constraint check failure for foo.T
Test.hx:16: characters 4-7 : String should be B
Test.hx:16: characters 4-7 : String should be { x : Int }
Test.hx:16: characters 4-7 : String has no field x
Test.hx:16: characters 4-7 : Constraint check failure for foo.T
Test.hx:16: characters 4-7 : String should be A
Test.hx:16: characters 4-7 : String should be { y : Int }
Test.hx:16: characters 4-7 : String has no field y
Whereas 'String should be A' is correct, 'String should be B' is incorrect.
The text was updated successfully, but these errors were encountered: