[erlang-bugs] type improper_list(_,_) undefined
Mon Sep 5 17:20:49 CEST 2011
On 09/05/11 17:18, John Hughes wrote:
> It looks as though the type improper_list/2 isn't defined in R14B02.
> Here's my file:
> -type ok() :: list(float()).
> -type foo() :: improper_list(float(),integer()).
> -type baz() :: maybe_improper_list(float(),integer()).
> Here's the output:
> 47> c(bug).
> ./bug.erl:5: type improper_list(_,_) undefined
> ./bug.erl:4: Warning: type ok() is unused
> ./bug.erl:5: Warning: type foo() is unused
> ./bug.erl:6: Warning: type baz() is unused
> And here's the documentation:
> List :: list(Type) %% Proper list (-terminated)
> | improper_list(Type1, Type2) %% Type1=contents, Type2=termination
> | maybe_improper_list(Type1, Type2) %% Type1 and Type2 as above
> Either I'm missing something very obvious, or the compiler doesn't know
> about improper_list.
The documentation needs updating. Use nonempty_improper_list/2 instead.
It's not only that we really wanted to discourage the use of these
types, but as a primitive, improper_list/2 does not make much sense when
the list can be empty. If you really need that type you can always
define it yourself as:
-type improper_list(T1,T2) ::  | nonempty_improper_list(T1,T2).
More information about the erlang-bugs