www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21714] New: misparse multi statement mixin in 'with' without

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

          Issue ID: 21714
           Summary: misparse multi statement mixin in 'with' without
                    brackets: all but the first statement are outside the
                    with
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following code:

enum Foo { A, B }

Foo a = Foo.A;

void main() {
    with (Foo) { mixin("Foo a = Foo.A; a = Foo.B;"); }
    assert(a == Foo.A);
    with (Foo) mixin("Foo a = Foo.A; a = Foo.B;");
    assert(a == Foo.A);
}

The assert fails, because the "a = Foo.B;" mixin statement inside the
bracketless with (Foo) gets put "after" the with. In other words, the
multi-statement mixin breaks out of its scope.

--
Mar 14