digitalmars.D.learn - Why are enums with base type string not considered strings?
- wolframw (15/15) Mar 14 2021 enum BoolEnum : bool { TestBool = false }
- Imperatorn (3/18) Mar 14 2021 May be a regression?
- Bastiaan Veelo (4/17) Mar 14 2021 Indeed: https://run.dlang.io/is/liSDBZ
- wolframw (16/26) Mar 16 2021 Thanks for the advice. I've since had a deeper look into this
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.
Mar 14 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
Mar 14 2021
On Sunday, 14 March 2021 at 16:09:39 UTC, Imperatorn wrote:On Sunday, 14 March 2021 at 10:42:17 UTC, wolframw wrote:Indeed: https://run.dlang.io/is/liSDBZ It regressed in 2.079.1. Seems to be worth an issue report. —Bastiaan.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 stringMay be a regression? https://issues.dlang.org/show_bug.cgi?id=16573
Mar 14 2021
On Sunday, 14 March 2021 at 16:30:47 UTC, Bastiaan Veelo wrote:On Sunday, 14 March 2021 at 16:09:39 UTC, Imperatorn wrote:Thanks for the advice. I've since had a deeper look into this located the PR that changed this behavior [1]. It seems this change was very much deliberate. In the PR, Jonathan also makes some points that are very hard to disagree with. So, perhaps the better solution would be to make isBoolean and isSomeChar (and perhaps other functions that I didn't think of) return false for enums? As a side note, isSomeChar returning true for enums is also what causes the behavior demonstrated in Issue 21639 [2]. [1] https://github.com/dlang/phobos/pull/5291 [2] https://issues.dlang.org/show_bug.cgi?id=21639On Sunday, 14 March 2021 at 10:42:17 UTC, wolframw wrote:Indeed: https://run.dlang.io/is/liSDBZ It regressed in 2.079.1. Seems to be worth an issue report. —Bastiaan.[...]May be a regression? https://issues.dlang.org/show_bug.cgi?id=16573
Mar 16 2021