D2 code: import std.ascii: uppercase; import std.string: maketrans; void main() { static r = maketrans(uppercase, uppercase[0 .. $]); } DMD 2.059head: test.d(4): Error: variable __dollar cannot be read at compile time test.d(4): called from here: maketrans(cast(const(char[]))uppercase,cast(const(char[]))uppercase[0u..__dollar])
D has no runtime initialization for static variables. Therefor the initializer must be constant. The error message could be better though.
cat > bug.d << CODE immutable char[5] foo = "abcde"; int bar(string a, string b) { return 0; } void baz() { enum s = bar(foo, foo[0 .. $]); } // Assertion failed: (!v->isDataseg() || v->isCTFE()), function push, file interpret.c, line 108. version (none) enum s = bar(foo, foo[0 .. $]); CODE dmd -c bug -------- Sorry, you're point was obviously that __dollar should be resolvable at compile time.
https://github.com/D-Programming-Language/dmd/pull/867
*** Issue 7771 has been marked as a duplicate of this issue. ***
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/59ee1fa13ff8f921bfe45307ea595fae7ea51fa7 Fix issue 7770 __dollar cannot be read at compile time It is always a CTFE variable, even if in global scope. https://github.com/D-Programming-Language/dmd/commit/4ff8864319107a802430cc1117fb560a1dcd6383 Merge pull request #867 from donc/ctfe7770dollar Fix issue 7770 __dollar cannot be read at compile time
*** Issue 8419 has been marked as a duplicate of this issue. ***
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル