-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@nogc: yields a wrong error where @nogc on each definition does not #19351
Labels
Comments
ketmar commented on 2017-12-20T13:34:43Zit's not *technically* incorrect: `@nogc:` affects *all* followind definitions, including lambdas. thus, in the second case, we actually have `auto __lambda () @nogc { new int(5); }`, and compiler complains. |
ketmar commented on 2017-12-20T13:35:28Z`return new int(5);`, of course, sorry. |
eyal commented on 2017-12-20T15:39:07ZIt does not affect other kinds of nested scopes.
For example, this does compile:
auto ignoreDlg(void function() dlg) {}
@nogc: struct S { void foo() { ignoreDlg(() { new int(5); }); } } |
ketmar commented on 2017-12-20T15:47:27Zyes, `struct` (and `class`, i believe) isn't affected. outer @nogc for *struct* (and class) doesn't change member attrs, only inner @nogc does. this is the logic compiler applies. ;-)
i'm still not sure if `@nogc` should do the same thing as `@nogc:` or not, tho. it prolly should, but let's wait for some compiler dev to clarify the things. |
eyal commented on 2017-12-20T16:31:09ZIt makes no sense at all for "@nogc" to apply to statements within a statement block of a function.
It would only make sense if it applied recursively to *all* nested scopes. |
timon.gehr commented on 2019-06-05T22:40:52ZThis is a more general problem, applying to other function attributes as well as @nogc.
The pull request below should be reverted as soon as this issue is fixed (it is an ugly hack fixing the problem only for the `static foreach` lowering and only for @nogc):
https://github.com/dlang/dmd/pull/9922/commits/0a65ef981578e263a380f6df4668572dce0a52d6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Eyal reported this on 2017-12-20T09:53:08Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=18106
CC List
Description
This compiles correctly: auto ignoreDlg(void function() dlg) {} @nogc void foo() { ignoreDlg({ new int(5); }); } But this gives an incorrect error about the "new" violating @nogc: auto ignoreDlg(void function() dlg) {} @nogc: void foo() { ignoreDlg({ new int(5); }); }The text was updated successfully, but these errors were encountered: