[Issue 16125] New: mixin string/template confusion, results in no-op

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jun 5 04:07:12 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16125

          Issue ID: 16125
           Summary: mixin string/template confusion, results in no-op
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: tomerfiliba at gmail.com

consider the following:

---------
enum Stub(string s) = s;

mixin Stub!"int x;";

void main() {
    writeln(x);     // error, x is undefined
}
--------

Stub!S obviously does different things under different conditions, but it
doesn't matter. it seems that dmd is confused by the the *syntax*, which looks
like mixin templates, while it's actually a string. so 

mixin "int x;"; 

is illegal in the syntax, but my code passes parsing, but simply doesn't do
anything. what i should have used is:

mixin(Foo!"int x;");

which works, but the previous version must either do the same or be a compiler
error.

--


More information about the Digitalmars-d-bugs mailing list