quint
quint copied to clipboard
Bad error message for missing parenthesis in the `if` condition
If the if
statement is inside an operator call (or probably anything), the parser loses track of the missing parenthesis error, and the reported error is almost meaningless:
module test {
val foo = Set(1, 2).map(x => if x > 0 { 1 } else { 2 })
}
test.qnt:2:26 - error: [QNT000] extraneous input '(' expecting {'}', 'const', 'var', 'assume', 'type', 'val', 'def', 'pure', 'action', 'run', 'temporal', 'import', 'export', DOCCOMMENT}
2: val foo = Set(1, 2).map(x => if x > 0 { 1 } else { 2 })
^
test.qnt:2:47 - error: [QNT000] extraneous input 'else' expecting {<EOF>, 'module', DOCCOMMENT}
2: val foo = Set(1, 2).map(x => if x > 0 { 1 } else { 2 })
^^^^
error: parsing failed
I realize this is only tangentially related, but might it be possible to get rid of the paren requirement altogether?
Rust and OCaml do it :), though OCaml has the benefit of using the then
keyword. Rust doesn't need one, though.
One thing to consider is that rust requires the curly braces for the blocks, while we currently don't (which I like). I think my personal preference is to use then
, rather than mandating either parenthesis or curly braces.