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"));
i wanna follow the thread i suspect this has to do with an assignment to a temporary in the loop forcing eval of the ctfe thing, turning it from an alias symbol into a value. but using the `alias` keyword in the static foreach still does it which makes me not sure.
@BorisCarvajal created dlang/dmd pull request #13252 "Fix Issue 22421 - static foreach introduces semantic difference between indexing and iteration variable" fixing this issue: - Fix Issue 22421 - static foreach introduces semantic difference between indexing and iteration variable https://github.com/dlang/dmd/pull/13252
dlang/dmd pull request #13252 "Fix Issue 22421 - static foreach introduces semantic difference between indexing and iteration variable" was merged into master: - 888beec5512e676a59c7c8ef3bee532e9a519bc1 by Boris Carvajal: Fix Issue 22421 - static foreach introduces semantic difference between indexing and iteration variable https://github.com/dlang/dmd/pull/13252