www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22506] New: Accessing immutable AA in nogc with index


          Issue ID: 22506
           Summary: Accessing immutable AA in  nogc with index results in
                    compilation error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: muhammed.yucel bosagora.io

It will throw the following compilation error

  Error: indexing an associative array in ` nogc` function `app.myfunc` may
  a GC allocation

Here is a code example:

  immutable int[int] aa;

  shared static this () 
        aa[10] = 20;
        aa[20] = 30;

  int myfunc ()  nogc
        return aa[10];

Nov 12 2021