www.digitalmars.com         C & C++   DMDScript  

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

https://issues.dlang.org/show_bug.cgi?id=21571

          Issue ID: 21571
           Summary: goto across assignment to AA fails and reports false
                    Error
           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

~~~gotoskip.d
int main ()
{
   string[string] aa;
   goto A;               // line 4
   aa["X"] = "Y";        // line 5
A:
   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;
        A:


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

--
Jan 21