Skip to content

Add asOriginalType function for enums#5401

Merged
dlang-bot merged 1 commit intodlang:masterfrom
andralex:enum-representation
May 19, 2017
Merged

Add asOriginalType function for enums#5401
dlang-bot merged 1 commit intodlang:masterfrom
andralex:enum-representation

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
Contributor

Auto-merge toggled off

@JackStouffer
Copy link
Contributor

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
Contributor

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 force-pushed the enum-representation branch from 8951b9c to c4bad1b Compare May 19, 2017 01:51
@andralex andralex changed the title Add representation function for enums Add asOriginalType function for enums May 19, 2017
@andralex andralex force-pushed the enum-representation branch from c4bad1b to bf43110 Compare May 19, 2017 01:52
@dlang-bot dlang-bot merged commit 46a3cda into dlang:master May 19, 2017
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.

4 participants