Why are enums with base type string not considered strings?

Imperatorn johan_forsberg_86 at hotmail.com
Sun Mar 14 16:09:39 UTC 2021


On Sunday, 14 March 2021 at 10:42:17 UTC, wolframw wrote:
> enum BoolEnum   : bool   { TestBool   = false }
> enum CharEnum   : char   { TestChar   = 'A' }
> enum StringEnum : string { TestString = "Hello" }
>
> pragma(msg, isBoolean!BoolEnum);       // true
> pragma(msg, isSomeChar!CharEnum);      // true
> pragma(msg, isSomeString!StringEnum);  // false
>
> Why does isSomeString not return true for an enum with base 
> type string while
> other isX functions return true for enums with an according 
> base type X?
> Regarding whether enums should be considered by these 
> functions, I can see the
> case being made one of both ways (personally, I'd say they 
> should), but in the
> example above it seems that different rules are applied.

May be a regression?

https://issues.dlang.org/show_bug.cgi?id=16573


More information about the Digitalmars-d-learn mailing list