www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2376] New: CTFE fails on array literal of array literals of chars

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2376

           Summary: CTFE fails on array literal of array literals of chars
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


string foo(string[] ss)
{
    string r;
    r ~= ss[0]; // problem here
    return r;
}

enum r = foo([['c'], ['d']]);
----
cannot evaluate foo([['c'],['d']]) at compile time


-- 
Sep 27 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2376





------- Comment #1 from samukha voliacable.com  2008-09-27 06:57 -------
This applies to any array of arrays, not only chars. To workaround, initialize
r in foo to []:

string foo(string[] ss)
{
    string r = []; // Interestingly, "" doesn't work.
    r ~= ss[0];
    return r;
}

enum r = foo([['c'], ['d']]);

However, the result of foo is crippled in a way that it cannot be processed
further at compile time.

For example, pragma(msg, r) fails with Error: string expected for message, not
'['c']'

The bug is also present in dmd 1.


-- 
Sep 27 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2376





------- Comment #2 from matti.niemenmaa+dbugzilla iki.fi  2008-09-27 11:11
-------
This one's probably related to, if not a duplicate of, Issue 1059.


-- 
Sep 27 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2376





------- Comment #3 from bugzilla digitalmars.com  2008-10-04 01:31 -------
Please file pragma(msg, ['c']) as a separate report.


-- 
Oct 03 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2376





------- Comment #4 from samukha voliacable.com  2008-10-04 03:30 -------
done. http://d.puremagic.com/issues/show_bug.cgi?id=2391


-- 
Oct 04 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2376


bugzilla digitalmars.com changed:

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




------- Comment #5 from bugzilla digitalmars.com  2008-10-20 22:19 -------
Fixed dmd 1.036 and 2.020


-- 
Oct 20 2008