Bug 12101 – [CTFE] Can't return struct with closure during CTFE

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-07T11:01:28Z
Last change time
2024-12-13T18:16:44Z
Keywords
CTFE, rejects-valid
Assigned to
No Owner
Creator
Martin Nowak
Moved to GitHub: dmd#17639 →

Comments

Comment #0 by code — 2014-02-07T11:01:28Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17639 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB