haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Extracting enum values with <Void> does not allow compilation

Open EliteMasterEric opened this issue 1 year ago • 1 comments

Example: https://try.haxe.org/#F28DdCCc

This is an example simplified down from a case in which I wanted to use haxe-concurrent to perform a task, and then query the time at which it was completed once it finished.

Here, I have a valid case for using Void as the parameter of PromiseResult, but encounter the issue where I cannot access getResult().time because extracting the enum values requires a variable be assigned to a Void type, even if it is unused (as indicated by assigning it to _).

Switching from Void to typedef NoValue = {} would be annoying as then I would have to make every task I provide to the task executor return an empty value.

Should assigning _ to Void specifically be allowed, or is that too strange of a behavior? There is also the question of whether using Void as the type parameter of an enum is even valid in the first place.

EliteMasterEric avatar Feb 07 '24 04:02 EliteMasterEric

I suppose we should finally disallow type parameter Void for Haxe 5. See #3463.

Simn avatar Feb 07 '24 07:02 Simn