Bug 22191 – -betterC: Overeager try/catch prohibition

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-08-07T17:36:39Z
Last change time
2024-12-13T19:17:57Z
Keywords
betterC
Assigned to
No Owner
Creator
kinke
Moved to GitHub: dmd#19970 →

Comments

Comment #0 by kinke — 2021-08-07T17:36:39Z
``` void foo() nothrow {} void main() { try { foo(); } catch (Exception) {} } ``` The frontend removes the try/catch from the AST at some point, so this should compile with -betterC too but doesn't ('Error: Cannot use try-catch statements with -betterC').
Comment #1 by Ajieskola — 2021-08-16T18:59:08Z
I'd argue it's good that this one does not compile. Not because it couldn't be compiled, but because checking for redundant `catch`ing isn't required behaviour in the spec. Programs that do this as -betterC would be relying on implementation-specific functionality.
Comment #2 by razvan.nitu1305 — 2023-04-10T10:06:20Z
Yes, I agree with Ate on this one. Maybe this should be the job of a linting tool.
Comment #3 by robert.schadek — 2024-12-13T19:17:57Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19970 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB