[Issue 15064] [CTFE] AliasSeq in multi-level alias this fails in CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 18 12:03:30 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=15064
Simen Kjaeraas <simen.kjaras at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |simen.kjaras at gmail.com
Component|phobos |dmd
Summary|[CTFE] std.range.enumerate |[CTFE] AliasSeq in
|is not CTFE-able |multi-level alias this
| |fails in CTFE
Severity|enhancement |normal
--- Comment #5 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Reduced test case:
import std.meta : AliasSeq;
struct Super {
AliasSeq!(int, int) expand;
alias expand this;
}
struct Tuple {
Super inner;
alias inner this;
}
struct Range {
Tuple front;
void popFront() {}
bool empty = true;
}
int test1() {
import std.algorithm : map;
foreach (i, e; Range.init) {} // Fails
foreach (i, e; [Tuple.init].map!(a=>a)) {} // Fails
foreach (i, e; [Tuple.init]) {} // Works [line 23]
return 3;
}
enum s1 = test1();
And even more reduced, I think:
struct Super2 {
AliasSeq!int expand;
alias expand this;
}
struct Tuple2 {
Super2 inner;
alias inner this;
}
int test2() {
AliasSeq!int a = Tuple2.init; // Fails with same message
int b = Tuple2.init[0]; // Works [line 41]
return 3;
}
enum s2 = test2();
Since test2 gives the same error message, and the same kind of unpacking will
happen in both cases, I assume that's the root problem.
So in summary: If an AliasSeq is used in alias this inside another alias this,
some context goes missing in CTFE, possibly only during tuple assignment (see
line 41). Strangely, it seems to work when the unpacking comes from an array
instead of a range (line 23). Not sure why that is, but it seems tangential to
the real problem here.
--
More information about the Digitalmars-d-bugs
mailing list