Thread overview
[Issue 980] New: If a function tries to concatenate a char to a empty array, dmd complains that the function can't be evaluated at compile time
Feb 18, 2007
d-bugmail
Feb 27, 2007
d-bugmail
Mar 08, 2007
d-bugmail
February 18, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=980

           Summary: If a function tries to concatenate a char to a empty
                    array, dmd complains that the function can't be
                    evaluated at compile time
           Product: D
           Version: 1.006
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: teleledningsanka@gmail.com


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);
}


-- 

February 27, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=980


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla@digitalmars.com  2007-02-26 19:26 -------
Fixed DMD 1.007


-- 

March 08, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=980





------- Comment #2 from thomas-dloop@kuehne.cn  2007-03-08 10:31 -------
Added to DStress as http://dstress.kuehne.cn/compile/o/opCatAssign_22_A.d http://dstress.kuehne.cn/compile/o/opCatAssign_22_B.d http://dstress.kuehne.cn//compile/o/opCat_26_A.d http://dstress.kuehne.cn//compile/o/opCat_26_B.d


--