www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21571] New: goto across assignment to AA fails and reports


          Issue ID: 21571
           Summary: goto across assignment to AA fails and reports false
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

int main ()
   string[string] aa;
   goto A;               // line 4
   aa["X"] = "Y";        // line 5
   return 0;

$ dmd gotoskip.d
gotoskip.d(4): Error: goto skips declaration of variable gotoskip.main.__aaval2
at gotoskip.d(5)

As mentioned by Paul Backus [1] the compiler generates a temporary for
the assigned value:

        // goto A;
        (string __aaval2 = "Y";) , aa["X"] = __aaval2;

http://forum.dlang.org/thread/zodxcypeddafyqruzxnw forum.dlang.org#post-fplpglzhvxckvryubwsc:40forum.dlang.org

Jan 21 2021