cat > bug.d << CODE
import std.algorithm, std.array, std.range;
auto addPrefix(R)(R rng, string prefix)
{
return rng.map!(a => prefix ~ a)();
}
enum files1 = ["a", "b"].addPrefix("1");
enum files2 = ["c", "d"].addPrefix("2");
enum allFiles = chain(files1, files2).array();
CODE
dmd -c bug.d
----
bug.d(5): Error: variable prefix cannot be read at compile time
----
Sorry, it's not very reduced, but I don't have time to do this right now.
Still wanted to report this.
Comment #1 by dlang-bugzilla — 2017-07-03T21:00:48Z
(In reply to Martin Nowak from comment #0)
> Sorry, it's not very reduced, but I don't have time to do this right now.
Reduced:
//////////////// test.d ////////////////
auto makeBox(int value)
{
struct Box
{
int getValue() { return value; }
}
return Box();
}
enum value = makeBox(1).getValue();
////////////////////////////////////////
Looks like there is an issue returning closure structs in CTFE.
Comment #2 by robert.schadek — 2024-12-13T18:16:44Z