www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20410] New: ReplaceTypeUnless replaces enums with their


          Issue ID: 20410
           Summary: ReplaceTypeUnless replaces enums with their basetype
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: mail skoppe.eu

ReplaceTypeUnless (and probably ReplaceType) decay enums into their base types.
This causes issues with e.g. the Sumtype library, which expects its template
argument list to contain no duplicates. (internally sumtype uses
ReplaceTypeUnless as well, thereby invalidating its own invariant.)

import std.meta;
import std.typecons;
import std.traits;

enum Enum : string { foo = "Bar" }

alias seq = AliasSeq!(string, Nullable!string, Enum, Nullable!Enum);
alias replaced = ReplaceTypeUnless!(isBoolean, int, uint, seq);

pragma(msg, seq);      // prints: (string, Nullable!string, Enum,
pragma(msg, replaced); // prints: (string, Nullable!string, string,

void main() {

Nov 21 2019