www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [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

reply d-bugmail puremagic.com writes:
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);
}


-- 
Feb 18 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=980


bugzilla digitalmars.com changed:

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





Fixed DMD 1.007


-- 
Feb 26 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=980






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


-- 
Mar 08 2007