Consider this buildfile (notice erroneous endif instead of end):
./:
{{
diag dummy
if (true)
if (false)
exit "bad"
else
echo good
endif
elif (false) # <-- error points to this line
else
end
}}
This produces the following diagnostics:
buildfile:11:3: error: 'elif' after 'else'
This is quite confusing. In the real situation where I hit this it took me several frustrating minutes to figure out what's the cause.
I believe the reason for this is that we treat endif as a command which causes the subsequent elif to be attributed to the inner if. Feel like the low-hanging fix here would be to point to the else and perhaps also to the if that is the beginning of the if-else chain.
Also, would be good to check if there is any other if-else diagnostics like this that can be confusing and can be improved in a similar way.
Consider this
buildfile
(notice erroneousendif
instead ofend
):This produces the following diagnostics:
This is quite confusing. In the real situation where I hit this it took me several frustrating minutes to figure out what's the cause.
I believe the reason for this is that we treat
endif
as a command which causes the subsequentelif
to be attributed to the innerif
. Feel like the low-hanging fix here would be to point to theelse
and perhaps also to theif
that is the beginning of theif-else
chain.Also, would be good to check if there is any other
if-else
diagnostics like this that can be confusing and can be improved in a similar way.