Thread overview
[Issue 23551] Error messages for use of array literals in @nogc code should be improved`
Dec 12, 2022
mhh
Dec 12, 2022
Dennis
Dec 12, 2022
Grim Maple
Dec 12, 2022
Dlang Bot
Dec 17, 2022
Iain Buclaw
December 12, 2022
https://issues.dlang.org/show_bug.cgi?id=23551

--- Comment #1 from mhh <maxhaton@gmail.com> ---
Error: array literal in `@nogc` function `D main` may cause a GC allocation

is not precise enough.

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

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |dkorpel@live.nl
           Hardware|x86                         |All
                 OS|Windows                     |All

--- Comment #2 from Dennis <dkorpel@live.nl> ---
What is the expected message?

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

Grim Maple <grimmaple95@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |grimmaple95@gmail.com

--- Comment #3 from Grim Maple <grimmaple95@gmail.com> ---
(In reply to Dennis from comment #2)
> What is the expected message?

The error itself targets this line
```
auto b = x[0..1];
```

which isn't what causes the issue. It's this line
```
enum x = [1,4];
```
which prevents slicing from being @nogc compatible. If changed to static
immutable x = [1,4]; code compiles fine

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

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@maxhaton created dlang/dmd pull request #14690 "Fix Issue 23551 - Start making nogc error messages for array literals…" fixing this issue:

- Fix Issue 23551 - Start making nogc error messages for array literals more precise

  This makes it more obvious what the array literal is, the greater issue is to
know where it was lowered from. More on that soon.

https://github.com/dlang/dmd/pull/14690

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=23551

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/20204

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--