Compiler bug

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

Compiler bug

Hakan Stenholm
>I found a compiler bug in R8B-0.  Here is the simplest test case
>I could come up with:
>
>-module(compiler_bug).
>-export([test/1]).
>
>test(A) when not is_list(A) -> A.

This shouldn't work:
* you can't use user defined functions (like is_list/1) in a guard,
  only type checks:
  atom/1, constant/1 ,float/1, integer/1, list/1, number/1, pid/1,
  port/1, reference/1, tuple/1, binary/1, record/2
 
  comparision operartors:
  >,<,=<,>=,==,/=,=:=,=/=
 
  and some bifs (together with arithmeteric ops):
  element/2, float/1, hd/1, length/1, round/1, self/0, size/1,
  trunc/1, tl/1, abs/1, node/1, node/0, nodes/0
 
* I'm not sure if "and", "or" and "not" can be used (, and ; can be used in a
  when statement to get "and" and "or" behaviour).  



Reply | Threaded
Open this post in threaded view
|

Compiler bug

Björn Gustavsson-3
The example is legal Erlang code.

is_list/1 is a type check (from R8). "and", "or", and "not" are now allowed
(from R8).

There really is a bug in the compiler.

A bug fix will probably be included in the next OS release of R8B.

/Bjorn

Hakan Stenholm <etxhste> writes:

> >I found a compiler bug in R8B-0.  Here is the simplest test case
> >I could come up with:
> >
> >-module(compiler_bug).
> >-export([test/1]).
> >
> >test(A) when not is_list(A) -> A.
>
> This shouldn't work:
> * you can't use user defined functions (like is_list/1) in a guard,
>   only type checks:
>   atom/1, constant/1 ,float/1, integer/1, list/1, number/1, pid/1,
>   port/1, reference/1, tuple/1, binary/1, record/2
>  
>   comparision operartors:
>   >,<,=<,>=,==,/=,=:=,=/=
>  
>   and some bifs (together with arithmeteric ops):
>   element/2, float/1, hd/1, length/1, round/1, self/0, size/1,
>   trunc/1, tl/1, abs/1, node/1, node/0, nodes/0
>  
> * I'm not sure if "and", "or" and "not" can be used (, and ; can be used in a
>   when statement to get "and" and "or" behaviour).  
>

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