[Issue 22421] New: static foreach introduces semantic difference between indexing and iteration variable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 18 18:57:48 UTC 2021
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 at puremagic.com
Reporter: andrei at 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"));
--
More information about the Digitalmars-d-bugs
mailing list