[Issue 21714] New: misparse multi statement mixin in 'with' without brackets: all but the first statement are outside the with
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 14 11:59:40 UTC 2021
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 at puremagic.com
Reporter: default_357-line at 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.
--
More information about the Digitalmars-d-bugs
mailing list