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

Struct<NativeEnum, EnumHandler> does not work in switch expression #1131

Open
kevinresol opened this issue Jul 23, 2024 · 0 comments
Open

Struct<NativeEnum, EnumHandler> does not work in switch expression #1131

kevinresol opened this issue Jul 23, 2024 · 0 comments

Comments

@kevinresol
Copy link

I stumbled across this issue #441 which points to this example code:
https://github.com/HaxeFoundation/hxcpp/blob/8eeeee784cca9a271c023030d56e3f6db426076c/test/native/tests/TestNativeEnum.hx

Equality check ((...:SystemMetricStruct) == OS) in Haxe generates this c++ code, which works ✅ :

cpp::Struct<wxSystemMetric, cpp::EnumHandler> val = // ...
if (::hx::IsInstanceEq( wxSYS_OS, val )) { ... }

Switch case (switch (...:SystemMetricStruct) {case OS: ... }) in Haxe generates this c++ code, which does not work ❌ :

cpp::Struct<wxSystemMetric, cpp::EnumHandler> _hx_switch_0 = // ...
if (  (_hx_switch_0==wxSYS_OS) ) { ... }
Error: ./src/RunTests.cpp:235:34: error: use of overloaded operator '==' is ambiguous (with operand types 'cpp::Struct<wxSystemMetric, cpp::EnumHandler>' and 'wxSYS_OS')
                        if (  (_hx_switch_0==wxSYS_OS) ){
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

No branches or pull requests

1 participant