Thread overview
[Issue 6457] New: [CTFE] .idup or casting of char[] does not really create a string literal recognizable in 'mixin', which causes a line-less error
Aug 08, 2011
kennytm@gmail.com
Aug 08, 2011
Trass3r
Aug 09, 2011
Don
Aug 10, 2011
Don
Aug 14, 2011
Trass3r
August 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6457

           Summary: [CTFE] .idup or casting of char[] does not really
                    create a string literal recognizable in 'mixin', which
                    causes a line-less error
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com
            Blocks: 5373


--- Comment #0 from kennytm@gmail.com 2011-08-08 14:11:52 PDT ---
Test case:

-----------------------------
string bug6457() {
    auto d = new char[6];
    d[] = "int a;";
    return d.idup;           // <-- won't make a real string
    // return cast(string)d; // <-- neither does this
}
mixin(bug6457());
-----------------------------
Error: argument to mixin must be a string, not (['i','n','t',' ','a',';'])
-----------------------------

This affects all codes that uses std.array.appender. 'mixin' should be able to accept a string casted/idup-ed from a 'char[]', or the interpreter should be able to convert a 'char[]' expression to a StringExp in a 'cast(string)', and no matter which solution is taken, the error of 'mixin' should have the line number.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6457


Trass3r <mrmocool@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool@gmx.de


--- Comment #1 from Trass3r <mrmocool@gmx.de> 2011-08-08 16:24:43 PDT ---
Isn't this even a regression?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6457


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-08-08 21:29:39 PDT ---
This doesn't work either, and it doesn't involve CTFE:

const char[] s = ['i','n','t',' ','a',';'];
mixin(s);
It's one of the few cases where arrays literals of chars aren't being accepted
as string literals.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6457


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-08-10 02:56:20 PDT ---
This particular test case is fixed in this commit:

https://github.com/D-Programming-Language/dmd/commit/df2b9cdff0f5c23449be7a6b9a875bcf92b38f8d

I created bug 6462 for the test case in comment 2, which has does not involve CTFE.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6457



--- Comment #4 from Trass3r <mrmocool@gmx.de> 2011-08-14 13:23:07 PDT ---
Another test case which still triggers that error is bug 5373.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------