digitalmars.D.bugs - [Issue 22421] New: static foreach introduces semantic difference
- d-bugmail puremagic.com (38/38) Oct 18 2021 https://issues.dlang.org/show_bug.cgi?id=22421
https://issues.dlang.org/show_bug.cgi?id=22421 Issue ID: 22421 Summary: static foreach introduces semantic difference between indexing and iteration variable Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: andrei erdani.com Consider the code below. Both versions should work the same, but the second causes an assertion error. alias AliasSeq(T...) = T; version(works) template staticMap(alias fun, args...) { alias staticMap = AliasSeq!(); static foreach(i; 0 .. args.length) staticMap = AliasSeq!(staticMap, fun!(args[i])); } else // BUG below template staticMap(alias fun, args...) { alias staticMap = AliasSeq!(); static foreach(arg; args) staticMap = AliasSeq!(staticMap, fun!arg); } template id(alias what) { enum id = __traits(identifier, what); } enum A { a } static assert(staticMap!(id, A.a) == AliasSeq!("a")); --
Oct 18 2021