Bug 21803 – "@nogc:" incorrectly propagates into function blocks, explicit "pure" too

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-04-05T22:44:46Z
Last change time
2024-12-13T19:15:45Z
Assigned to
No Owner
Creator
Eyal
Moved to GitHub: dmd#19904 →

Comments

Comment #0 by eyal — 2021-04-05T22:44:46Z
This compiles successfully: struct S { @nogc void f() { scope dlg = { new int; }; } } Whereas this doesn't, because it complains the "new" violates @nogc. struct T { @nogc: void f() { scope dlg = { new int; }; } }
Comment #1 by eyal — 2021-04-05T22:47:35Z
A pure function incorrectly taints all delegates declared within it as pure as well. For example, this compiles: __gshared string global; struct S { auto f() { scope dlg = { throw new Exception(global); }; } static assert(hasFunctionAttributes!(f, "pure")); } But this complains about the use of the global: struct T { pure void f() { scope dlg = { throw new Exception(global); }; } }
Comment #2 by eyal — 2021-04-05T22:50:17Z
Interestingly, @safe/nothrow seem to behave just fine.
Comment #3 by robert.schadek — 2024-12-13T19:15:45Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19904 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB