Compiler bug?

Richard Carlsson richardc@REDACTED
Thu Feb 20 10:28:33 CET 2003


On Thu, 20 Feb 2003, Erik Reitsma (ETM) wrote:

> Because of a silly typo I stumbled onto what seems to be a bug in
> the compiler. The compiler crashes on the following module:
> ------------
> -module(t).
> 
> -export([a/0]).
> 
> a() ->
>     .list_to_atom("ok").
> ------------
> I get an internal error in beam_clean, with a case_clause.
> I know that this should not compile, but I would expect a nicer
> error message.


Thanks. I'll try to fix this promptly.

What happens is that the initial period makes it look like a call
'F("ok")', so the lookup for a BIF or a local function is skipped. Then
it turns out that the assumed "functional value" is the atom
'list_to_atom', and the Beam backend dies horribly.

It's as if you had written:

	F = list_to_atom,
	F("ok")

and the value of F got inlined after the linter had checked the code.
(It is one of the weird quirks of Erlang that this does not mean the
same thing.)

	/Richard


Richard Carlsson (richardc@REDACTED)   (This space intentionally left blank.)
E-mail: Richard.Carlsson@REDACTED	WWW: http://user.it.uu.se/~richardc/




More information about the erlang-questions mailing list