[Issue 21694] New: Misleading error message and invalid goto error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 9 13:22:08 UTC 2021


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

          Issue ID: 21694
           Summary: Misleading error message and invalid goto error
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: rumbu at rumbu.ro

struct A { ~this() {} }

void test(int x)
{
   {
      A a;
      goto END;
   }
   A b;

END:
}

Error: cannot `goto` into `try` block

I know that behind the scenes the code above will end in two imbricated
try/finally blocks because of RAII, but:
- the error message is misleading, there is no finally block in the original
code;
- this is a legal goto equivalent with a return which should be allowed, it's
not like jumping in a middle of another scope (which also shows the same
misleading error message).

--


More information about the Digitalmars-d-bugs mailing list