[Issue 24300] New: error message for a jump over `scope(exit)` leaks internal details

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 25 16:10:14 UTC 2023


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

          Issue ID: 24300
           Summary: error message for a jump over `scope(exit)` leaks
                    internal details
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

The error output for

```d
extern(C) int puts(const char*);

int main () {
  goto L0;
  scope(exit) puts("meow");

  L0:
  puts("cat says");

  return 0;
}  
```

is 

> Error: cannot `goto` into `try` block

This leaks the fact that the exit scope guard is lowered to a try-finally
statement,
a detail that does not necessarily interests the user or that can even be
confusing

A better message would be

> Error: cannot `goto` skip over `exit` scope guard

--


More information about the Digitalmars-d-bugs mailing list