Bug 980 – If a function tries to concatenate a char to a empty array, dmd complains that the function can't be evaluated at compile time

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-02-18T17:54:00Z
Last change time
2014-02-16T15:26:10Z
Assigned to
bugzilla
Creator
teleledningsanka

Comments

Comment #0 by teleledningsanka — 2007-02-18T17:54:59Z
If a function tries to concatenate a char to a empty char[] array, dmd gives the error "cannot evaluate ... at compile time". The same code works at runtime. The workaround is to simply initialize the string. Code that shows the bug: /* bug.d(12): Error: cannot evaluate (test)(0) at compile time bug.d(13): Error: string expected for message, not '(test)(0)' */ char[] test(int dummy = 0) { char[] s /*= ""*/ ; // Works if comment is removed return s ~ 't'; } void main() { const x = test(); pragma(msg, x); }
Comment #1 by bugzilla — 2007-02-26T19:26:48Z
Fixed DMD 1.007
Comment #2 by thomas-dloop — 2007-03-08T10:31:06Z