Thread overview
[Issue 18106] @nogc: yields a wrong error where @nogc on each definition does not
Dec 20, 2017
Ketmar Dark
Dec 20, 2017
Ketmar Dark
Dec 20, 2017
Eyal
Dec 20, 2017
Ketmar Dark
Dec 20, 2017
Eyal
Jun 05, 2019
timon.gehr@gmx.ch
Dec 17, 2022
Iain Buclaw
December 20, 2017
https://issues.dlang.org/show_bug.cgi?id=18106

--- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
it'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.

--
December 20, 2017
https://issues.dlang.org/show_bug.cgi?id=18106

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--- Comment #2 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
`return new int(5);`, of course, sorry.

--
December 20, 2017
https://issues.dlang.org/show_bug.cgi?id=18106

--- Comment #3 from Eyal <eyal@weka.io> ---
It 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); }); } }

--
December 20, 2017
https://issues.dlang.org/show_bug.cgi?id=18106

--- Comment #4 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
yes, `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.

--
December 20, 2017
https://issues.dlang.org/show_bug.cgi?id=18106

--- Comment #5 from Eyal <eyal@weka.io> ---
It 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.

--
June 05, 2019
https://issues.dlang.org/show_bug.cgi?id=18106

timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch

--- Comment #6 from timon.gehr@gmx.ch ---
This 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

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=18106

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

--