-
-
Notifications
You must be signed in to change notification settings - Fork 670
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
Only allow Void
in return types
#11558
base: development
Are you sure you want to change the base?
Conversation
# Conflicts: # src/typing/typeload.ml
🎉 for |
I'm kind of lying about the "only in return types" part here because there's also still the I'm not sure what to do with the old function syntax in general. The new one is objectively superior and I'm generally not a fan of having two ways to express the same thing. On the other hand, is it really worth breaking code over something so idealistic? I think it would take some sort of actual problem to justify this, and I don't remember if there are any. |
I'd say a major release is definitely as good a time as any to make a breaking change. Previous versions of Haxe will still exist, and if we never make this change, the quality and readability of Haxe code overall will suffer as a result. |
I'd say |
That's debatable because |
Why not remove |
Yes that's the question I'm asking, but in that case we surely should remove the old function type syntax entirely and not just this special case. |
I'm being too hasty with that haxe.NoValue change because it's not actually a NoValue type, but rather a Unit type. Consider this: class C<A> {
public function new() {}
public function invoke(a:A) {}
}
function main() {
var c = new C<haxe.NoValue>();
c.invoke(null /* here */);
} In order to call the invoke function, we need to pass a value at run-time. In that light, I think we need to add a |
I think we generally agree that we want to disallow
Void
for type parameters, but this by itself would be pointless if we still allowedtypedef NotVoid = Void
. This PR disallows loadingVoid
for anything that's not a function return type.Right now, it doesn't do this for externs yet because there are several places in js/html and hxnodejs that have
Promise<Void>
. I'm not sure what to do with that right now, but we'll have to figure this out before merging.I'm deleting the test for #6810 because that depends on typedeffing Void. However, the issue can be closed because it will no longer be relevant.
Edit: I forgot to mention something: We're also adding
haxe.NoValue
here which can be used instead ofVoid
.Closes #3463
Closes #6810
Closes #11555