[erlang-questions] Better error messages would be helpful

Anthony Ramine n.oxyde@REDACTED
Thu May 16 10:30:46 CEST 2013

Hello Richard,

To silence the undefined error, the parser would need to be able to know it indeed gave up on it; that is not so straightforward.

For the syntax error to be more useful, that also would require either heavy yecc surgery or rewritting erl_parse to be an handwritten descent-recursive parser --that is a thing I've always wanted to do.

For pairs we can indeed use epp to do it as it already needs to track them for macro arguments.

Otherwise we can still improve the situation quite a lot with just column numbers, when they get merged someday.


Anthony Ramine

Le 16 mai 2013 à 05:04, Richard A. O'Keefe a écrit :

> I'm in the middle of writing to someone who asked for help with
> some Erlang code.  With identifiers replaced, he had
> 21: f(A, B, C) ->
> 22:     D = lists:map(fun (E) ->
> 23:         case proplist:get_value(E, B, error) of
> 24:         {F} -> {E,F};
> 25:         error -> {error}
> 26:         end, A).
> erlc reported
> ./foobar.erl:26: syntax error before: ')'
> ./foobar.erl:16: function f/3 undefined
> When there are error messages that prevent any function from being processed,
> it would be helpful if erlc did *NOT* complain about undefined, because that
> message is untrue.  The function *was* defined, the compiler just gave up on
> it.
> But the message that really had him confused was the "syntax error before ')'"
> one.  This is the kind of error message one typically gets from something
> using Yacc-style parsing.
> I didn't like his layout, so I fed his file to an Erlang pretty-printer I
> wrote a couple of years.  The code is fast but rather horrible C, so I do
> not care to share it.  It was thrown together as an experiment, with an
> eye to using it in a text editor.  What did that pile of hacks say?
> 	Line 26: 'fun' at line 22 closed by ')' (expected 'end'). 
> So a better error message is certainly possible.
> This is a pretty-printer, not a parser.  Almost the only syntax checking it
> does is to keep track of brackets.  But bracket errors are common enough
> that it's worth while.
> I don't like the idea of slowing erlc down, but I wonder if decent bracket
> matching checks could be folded in with macro expansion without too much
> trouble?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list