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

[hl] Comparing null to 0 #8367

Closed
RealyUniqueName opened this issue Jun 4, 2019 · 5 comments
Closed

[hl] Comparing null to 0 #8367

RealyUniqueName opened this issue Jun 4, 2019 · 5 comments
Assignees
Labels
platform-hl Everything related to HashLink
Milestone

Comments

@RealyUniqueName
Copy link
Member

RealyUniqueName commented Jun 4, 2019

class Main {
	static function main() {
		function check(?i:Int) {
			trace(i == 0); // false
			trace(i < 0);  // false
			trace(i > 0);  // false
			trace(i <= 0); // true
			trace(i >= 0); // true
		}
		check();
	}
}
@RealyUniqueName RealyUniqueName added the platform-hl Everything related to HashLink label Jun 4, 2019
@RealyUniqueName RealyUniqueName modified the milestones: Bugs, Release 4.0 Jun 4, 2019
@ncannasse
Copy link
Member

Uhm. Seems like there is a null-to-int cast being done here.

@Simn
Copy link
Member

Simn commented Jun 14, 2019

genhl just determines a common type between the operands and then casts both to that type. This is fine for most cases but breaks semantics when Null<T> gets involved because we don't want to unwrap.

@Simn
Copy link
Member

Simn commented Jun 14, 2019

Also I'm mildly shocked that our tests don't cover this.

@Simn
Copy link
Member

Simn commented Jul 1, 2019

This is pretty much superseded by #8426, but I just 4.1ed that due to gencommon cancer. Feel free to 4.1 or close this one as well if you don't want to look into it for HL at the moment.

@RealyUniqueName
Copy link
Member Author

I'm closing this because it's a part of #8426 indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-hl Everything related to HashLink
Projects
None yet
Development

No branches or pull requests

3 participants