Bug 12382 – `opDollar` can't be used at CT

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-16T06:58:00Z
Last change time
2014-03-23T17:12:04Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2014-03-16T06:58:43Z
This code used to work: --- struct S { size_t opDollar() { return 0; } size_t opIndex(size_t) { return 0; } } enum e = S.init[$]; // line 7 --- main.d(7): Error: static variable __dollar cannot be read at compile time main.d(7): called from here: S().opIndex(__dollar) --- This is a rather old regression.
Comment #1 by dlang-bugzilla — 2014-03-17T00:54:38Z
When did it work? opDollar was implemented in 2.057 and the code doesn't compile in any version since then.
Comment #2 by verylonglogin.reg — 2014-03-17T06:18:59Z
Comment #3 by k.hara.pg — 2014-03-17T08:02:43Z
Comment #4 by github-bugzilla — 2014-03-23T03:07:19Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4c97247132864c2dea65f6743392261c90ec8ac0 fix Issue 12382 - `opDollar` can't be used at CT Front-end should handle opDollar side-effect carefully, because CTFE engine cannot interpret `(auto __dollar = obj.opDollar(), obj).opIndex(__dollar)` without CTFE stack. https://github.com/D-Programming-Language/dmd/commit/efe0e45fecfa2b324ae382e77e6456a419abc657 Merge pull request #3385 from 9rnsr/fix12382 Issue 12382 - `opDollar` can't be used at CT