Compiler bug?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiler bug?

Erik Reitsma (RY/ETM)-2
Hi,

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.

*Erik.


Reply | Threaded
Open this post in threaded view
|

Compiler bug?

Richard Carlsson-4

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)   (This space intentionally left blank.)
E-mail: Richard.Carlsson WWW: http://user.it.uu.se/~richardc/



Reply | Threaded
Open this post in threaded view
|

Compiler bug?

Björn Gustavsson-3
In reply to this post by Erik Reitsma (RY/ETM)-2
Thanks for the bug report.

I agree that the compiler should not crash whatever input you give it.

The bug will be fixed in the next major OTP release.

/Bjorn

"Erik Reitsma (ETM)" <Erik.Reitsma> writes:

> Hi,
>
> 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.
>
> *Erik.
>

--
Bj?rn Gustavsson            Ericsson Utvecklings AB
bjorn      ?T2/UAB/F/P
                            BOX 1505
+46 8 727 56 87    125 25 ?lvsj?