www.digitalmars.com         C & C++   DMDScript  

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

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 puremagic.com
          Reporter: tomerfiliba 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.

--
Jun 05 2016