Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 21, 2019 [Issue 20410] ReplaceTypeUnless replaces enums with their basetype | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20410 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simen.kjaras@gmail.com --- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> --- This is only true where the base type of the enum fits one of the other patterns that ReplaceTypeUnless looks for, e.g. U[], U*, etc. - it will leave regular enums well enough alone, but string enums and the like will decay to their base types. Of course, there is a discussion to be had here - should the type change if I do this? import std.typecons : ReplaceType; enum Foo : string { bar = "baz" } pragma(msg, ReplaceType!(char, int, Foo)); Currently, that'd be immutable(int)[], since Foo is a kind of immutable(char)[], and I've asked to replace char with int. While there are arguments to be had on both sides of this, I'd go with treating enums as opaque, since it's easier to forcibly decay them than filter them out beforehand. Should be a simple two lines here: https://github.com/dlang/phobos/blob/58cb6963fbe54e7dc96ae8b48064e84f1eaf818a/std/typecons.d#L8748 else static if (is(T[0] == enum)) alias ReplaceTypeUnless = T; test case: @safe unittest { enum Enum : string { foo = "Bar" } assert(is(ReplaceType!(char, int, Enum)[0] == Enum)); } -- |
November 22, 2019 [Issue 20410] ReplaceTypeUnless replaces enums with their basetype | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20410 Paul Backus <snarwin+bugzilla@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |snarwin+bugzilla@gmail.com Component|phobos |dmd --- Comment #2 from Paul Backus <snarwin+bugzilla@gmail.com> --- Looks like a bug in the is expression. The "true" below ought to be "false": enum Enum : string { foo = "bar" } pragma(msg, is(Enum == string)); // false pragma(msg, is(Enum == T[], T)); // true pragma(msg, T); // immutable(char) -- |
June 06, 2020 [Issue 20410] ReplaceTypeUnless replaces enums with their basetype | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20410 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> --- @pbackus updated dlang/dmd pull request #11235 "Fix 20410 - ReplaceTypeUnless replaces enums with their basetype" fixing this issue: - Fix issue 20410 - ReplaceTypeUnless replaces enums with their basetype When matching an enum against a type specialization, a match obtained using the enum's base type is now correctly considered a match by implicit conversion rather than an exact match. https://github.com/dlang/dmd/pull/11235 -- |
June 06, 2020 [Issue 20410] ReplaceTypeUnless replaces enums with their basetype | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20410 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> --- dlang/dmd pull request #11235 "Fix 20410 - ReplaceTypeUnless replaces enums with their basetype" was merged into master: - 98259447cd40f28b539574dacd822a11aeb8167c by Paul Backus: Fix issue 20410 - ReplaceTypeUnless replaces enums with their basetype When matching an enum against a type specialization, a match obtained using the enum's base type is now correctly considered a match by implicit conversion rather than an exact match. https://github.com/dlang/dmd/pull/11235 -- |
Copyright © 1999-2021 by the D Language Foundation