You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When comparing enums with arguments directly, Haxe raises the expected error:
You cannot directly compare enums with arguments. Use either `switch`, `match` or `Type.enumEq`
However, when this comparison is performed inside a setter, the error is not triggered, and the setter logic does not function as intended. Specifically, the state is updated every time, even if the new value is identical to the current value.
In the setter, the comparison should trigger the same error as in other contexts, enforcing the use of switch, match, or Type.enumEq for enums with arguments.
Actual Behavior:
No error is raised, and the state updates even when the new value matches the current state, resulting in unexpected behavior.
This has nothing to do with setters, the problem is that this error only triggers when you explicitly compare against Collapsed(true). This is the only case in which the compiler can be sure that you're wrong.
Something we could consider is a flag that detects direct comparisons and complains about it for any enum that has a constructor with arguments. I suppose this could be an optional warning.
When comparing enums with arguments directly, Haxe raises the expected error:
However, when this comparison is performed inside a setter, the error is not triggered, and the setter logic does not function as intended. Specifically, the state is updated every time, even if the new value is identical to the current value.
Produces the following output:
Expected Behavior:
In the setter, the comparison should trigger the same error as in other contexts, enforcing the use of
switch
,match
, orType.enumEq
for enums with arguments.Actual Behavior:
No error is raised, and the state updates even when the new value matches the current state, resulting in unexpected behavior.
Environment
Haxe 4.3.6 (public playground)
The text was updated successfully, but these errors were encountered: