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

Add asOriginalType function for enums #5401

Merged
merged 1 commit into from May 19, 2017

Conversation

andralex
Copy link
Member

In order to fix https://issues.dlang.org/show_bug.cgi?id=6227, we need to recommend the appropriate way of comparing different enum types if the user wants so. This supports that.

@WalterBright
Copy link
Member

Auto-merge toggled on

@JackStouffer
Copy link
Member

Auto-merge toggled off

@JackStouffer
Copy link
Member

I'm not sure I follow as to why this is fixing the linked bug when the bug talks about DMD giving no warning about the comparison of different enum types when this function is about enum manifest constants.

@andralex
Copy link
Member Author

@JackStouffer The idea is to have the error message say: "Cannot compare unrelated enums, use std.conv.representation to convert each or both to their representation type".

@WalterBright
Copy link
Member

This function gives a safe way to convert the enums being compared to a comparable type.

@JackStouffer
Copy link
Member

Ah, ok. Be careful though, as Phobos already has a function called representation in std.string.

@andralex
Copy link
Member Author

Yah, the use of the same name is intentional.

@andralex
Copy link
Member Author

Let me rename it to asOriginalType which plays nice with OriginalType

@andralex andralex changed the title Add representation function for enums Add asOriginalType function for enums May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants