Empty lambda produces poor error message
If the user writes \ -> body
, they get this unhelpful error message:
ghci> \ -> ()
<interactive>:1:3: error: parse error on input ‘->’
Furthermore, this is a fatal parse error, so we cannot report any other error in the file.
The fix is easy. Change the following production in the parser:
- | '\\' apat apats '->' exp
+ | '\\' apats '->' exp
And do the validation in checkFunBind
using addError
(but not addFatalError
, which would prevent error recovery).
While we could also simply allow the nullary lambda (to me, it looks as reasonable as nullary let
, e.g. let in ...
), that would probably require a proposal. For now, we can continue to reject, but with an improved error message.