Bug 21714 – misparse multi statement mixin in 'with' without brackets: all but the first statement are outside the with

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-03-14T11:59:40Z
Last change time
2024-12-13T19:15:12Z
Assigned to
No Owner
Creator
FeepingCreature
Moved to GitHub: dmd#19888 →

Comments

Comment #0 by default_357-line — 2021-03-14T11:59:40Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:15:12Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19888 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB