fuzion
fuzion copied to clipboard
dangling else should cause error if everything is in one line
This is a variant of the dangling else problem, which we also have and should solve similarly by producing an error.
Originally posted by @fridis in https://github.com/tokiwa-software/fuzion/issues/2702#issuecomment-2270891573
Currently the dangling else belongs to the inner if.
The error could look something like this
> fz -e 'if true if false then say "inner true" else say "dangling else"'
command line:1:47: error 1: Ambiguous else block.
if true if false then say "inner true" else say "dangling else"
---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^
It is unclear whether the else block belongs to the outer or inner if.
To solve this, add braces { } or use line breaks and indentation.