-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typedef and Interface #11026
Comments
The error you're getting is not related to an interface. This fails too: typedef TFoo = {
a:Int,
b:Int
}
class MyClass {
public function new() {}
public function get():TFoo {
return { a: 0, b: 0, c: 0 }
}
} The reason is that if you specify the return type, the compiler uses it for top down inference and you have the same type error as |
Hej Juraj, Thx for your answer. |
But there is maybe something with variance because if for example the function doesn't return "a", compiler does throw an error as expected. So feel free to close this, I just wanted to point that |
I suppose the question here is if the return type should be typed against the type from the interface, which on first glance sounds like a good idea. |
Hej,
I don't know if it's intentional but I just realized that Haxe doesn't complain here : https://try.haxe.org/#729BD642
If the return type is uncommented it does complain as it should, but without, it should also complain at least that the return type isn't the same as in the interface right ?
The text was updated successfully, but these errors were encountered: