Skip to content

Conversation

@Simn
Copy link
Member

@Simn Simn commented Dec 12, 2025

The idea here is to resolve abstract operator overloads only if the nullability of the expression type matches the nullability of the argument.

Not ready yet, I just need an issue number for tests.

@Simn
Copy link
Member Author

Simn commented Dec 12, 2025

Hmm, this was way easier than expected... one change I'm making here is to remove @:notNull from Int64 on the flash target, because I don't think that's correct. The native representation on that target is a class, so we shouldn't pretend otherwise.

@yuxiaomao Could you check some of your codebases with this PR?

@Simn Simn marked this pull request as ready for review December 12, 2025 08:32
@Simn
Copy link
Member Author

Simn commented Dec 12, 2025

As expected there are some problems for cases such as this:

abstract T(Float) from Float {
	@:op(A + B) public function addFloat(f:Float) {
		return this + f;
	}
}

function main() {
	var t:T = 0.0;
	var nullFloat:Null<Float> = 1.0;
	trace(t + nullFloat); // T should be Float
}

The binop used to resolve to the @:op function, but with Null<Float> and Float having different nullability, that no longer works. I consider this an improvement, but it remains to be seen if this is something we can adapt to.

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

Successfully merging this pull request may close these issues.

2 participants