[Issue 23983] Better error message when brace missing after `else`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 12 15:15:44 UTC 2023


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

--- Comment #4 from Dennis <dkorpel at live.nl> ---
(In reply to ryuukk_ from comment #3)
> In example 2, it complains at bunch of things, then at the end it says
> closing braces at line 21; but the problem is actually at line 8

A human could guess the problem is at line 8, but formally, the else branch is
not required to have braces, and the } after the else branch could close the
main function. 

> Now imagine if you have lot more code in between, have fun guessing where
> the problem really is, reason why i opened this issue is because it just
> happened to me, it's not fun

I understand and agree, I'm just wondering how the compiler could
algorithmically find out the problem is likely at line 8. Perhaps it could take
note of the mismatched indentation of the closing brace after else, and report
that once it encounters a missing brace error.

--


More information about the Digitalmars-d-bugs mailing list