Skip to content
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

Unexpected implicit cast to Int, from abstract(Null<Int>) #696

Closed
Geokureli opened this issue Jul 1, 2024 · 2 comments
Closed

Unexpected implicit cast to Int, from abstract(Null<Int>) #696

Geokureli opened this issue Jul 1, 2024 · 2 comments

Comments

@Geokureli
Copy link

Geokureli commented Jul 1, 2024

Example:

class Test {
	static var foo:Foo = null;

	static function main() {
		trace(switch (foo) {
			case B: "B";
			case A: "A";
			default: "B";
		});
		// Outputs "A" only on hashlink, otherwise B
	}
}

enum abstract Foo(Null<Int>) {
	public var A = 0;
	public var B = 1;
}

looks as though an int cast is converting null to 0, despite that null is a valid value for foo. We were able to work around this by adding case null: up top, but still seems like a bug

@yuxiaomao
Copy link
Collaborator

Fixed in haxe

@Geokureli
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants