[erlang-questions] erlc: interesting error message

Tuncer Ayaz tuncer.ayaz@REDACTED
Thu Jan 23 17:05:52 CET 2014


I just stumbled upon an interesting erlc error message. It's not a big
issue, but when I saw the error I wondered if this is desired
behavior. I mean, is this something that can and should be improved to
provide a more descriptive error message? Thoughts?

$ cat foo.erl
-module(foo).

-include("foo.hrl").

-export([foo/0]).

foo() -> io:format("foo").
$ cat foo.hrl
-define(FOO, bar).

baz
$ erlc foo.erl
foo.hrl:3: syntax error before:

$ erl
1> compile:file("foo.erl", [return]).
{error,[{"foo.hrl",
          [{3,erl_parse,["syntax error before: ",[]]}]}],
        []}


Same message if you append "foo\n" to foo.erl:
$ cat foo.erl
-module(foo).

-include("foo.hrl").

-export([foo/0]).

foo() -> io:format("foo.").
foo
$ erlc foo.erl
foo.erl:8: syntax error before:
$ erl
1> compile:file("foo.erl",[return]).
{error,[{"foo.erl",
          [{8,erl_parse,["syntax error before: ",[]]}]},
         {"foo.hrl",[{3,erl_parse,["syntax error before: ",[]]}]}],
        []}

As a test I've replaced line 2 in foo.hrl with "foo\n":
$ cat foo.hrl
-define(FOO, bar).
foo
baz
$ erlc foo.erl
foo.erl:8: syntax error before:
foo.hrl:3: syntax error before: baz
$ erl
1> compile:file("foo.erl",[return]).
{error,[{"foo.erl",
          [{8,erl_parse,["syntax error before: ",[]]}]},
         {"foo.hrl",[{3,erl_parse,["syntax error before: ","baz"]}]}],
        []}



More information about the erlang-questions mailing list