-
Notifications
You must be signed in to change notification settings - Fork 5
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
Maybe not a bug. Safety: Cannot cast nullable value to not nullable type with Std.instance #17
Comments
This is for Haxe 4.0.0-preview.5 and Safety from master. |
This is an intended behavior for a typed cast: Safety/test/cases/TestCompileTime.hx Lines 505 to 509 in 9dc8579
However, Safety/test/cases/TestCompileTime.hx Lines 511 to 514 in 9dc8579
Maybe Haxe typer makes them indistinguishable for the Safety plugin in case of |
I think problem is in Std.instance signature, which is public static function instance<T:{},S:T>( value : T, c : Class<S> ) : S; However, documentation says:
Proper signature should be public static function instance<T:{},S:T>( value : T, c : Class<S> ) : Null<S>; I "fix" this by @:safety(unsafe)
public static function instanceExt<T : {}, S : T>(value : T, c : Class<S>) : Null<S> {
return Std.instance(value, c);
} I understand that this is something not on Safety side, but maybe you can propose this change for Haxe. |
See https://github.com/restorer/haxe-safety-bugs/blob/master/safetybugs/Main.hx#L163 for working example.
The text was updated successfully, but these errors were encountered: