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

Allow to create an enum from a macro symbol #8634

Merged
merged 3 commits into from
Dec 30, 2019

Conversation

bew
Copy link
Contributor

@bew bew commented Dec 28, 2019

Closes #8573

enum_value =
{% begin %}
SpecEnum.from_self({{ :two }})
{% end %}
Copy link
Contributor Author

@bew bew Dec 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I'm not sure why I need to use macro begin/end here, otherwise it fails with:
no overload matches 'SpecEnum.from_self' with type Symbol
I guess it's because auto-casted symbols are resolved earlier then macro expansion?

@bew
Copy link
Contributor Author

bew commented Dec 28, 2019

Pretty weird CI error for test_linux:

.build/std_spec: relocation error: .build/std_spec: symbol __gmon_start__ version LIBXML2_2.4.30 not defined in file libxml2.so.2 with link time reference

@asterite
Copy link
Member

To be honest I don't understand the use case. Why would you get a symbol from somewhere? And if you do get a symbol, why don't you compare symbols instead of enums?

@bew
Copy link
Contributor Author

bew commented Dec 28, 2019

@asterite in my case I had an annotation with symbols that should map to real enum values.
And then generated some code which should do various things based on the given enum values.

@RX14 RX14 merged commit 633116c into crystal-lang:master Dec 30, 2019
@bew bew deleted the allow-create-enum-from-macro-sym branch December 30, 2019 12:35
@bew
Copy link
Contributor Author

bew commented Dec 30, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to create an enum from a macro symbol
5 participants