[Issue 4428] New: string mixin of variable of type string fails

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 5 02:37:56 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4428

           Summary: string mixin of variable of type string fails
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jmdavisProg at gmail.com


--- Comment #0 from Jonathan M Davis <jmdavisProg at gmail.com> 2010-07-05 02:37:50 PDT ---
void main()
{
    string str = "writeln(\"hello world\");";
    mixin(str);
}


fails to compile, giving the errors

test.d(4): Error: argument to mixin must be a string, not (str)
test.d(4): Error: argument to mixin must be a string, not (str)


If you put the string in directly,

void main()
{
    mixin("writeln(\"hello world\");");
}


or if you create a function which returns the string and feed that into the
mixin

string getStr()
{
    return "writeln(\"hello world\");";
}

void main()
{
    mixin(getStr());
}


it compiles just fine. So, for some reason, mixin expressions fail when
handling string variables, but not if the string is supplied directly or as a
return value from a function. Obviously, it needs to be fixed so that mixin's
will actually mixin string variables rather than claiming that string variables
aren't strings.

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


More information about the Digitalmars-d-bugs mailing list