[erlang-questions] Type tuple won't compile

the.silly.sad the.silly.sad@REDACTED
Tue Dec 30 19:54:52 CET 2014


On 12/30/2014 05:52 PM, Luis Rascão wrote:
> Hi all,
> I'm having a hard time figuring out why the following code won't compile:
>
> -module(t).
>
> -export([test/1]).
>
> -record(map, {a, b}).
> -type map() :: #map{}.
>
> -record(tuple, {a, b}).
> -type tuple() :: #tuple{}.
>
> -record(list, {a, b}).
> -type list() :: #list{}.
>
> -spec test(map() | tuple() | list()) -> map | tuple | list.
> test(#map{}) -> map;
> test(#tuple{}) -> tuple;
> test(#list{}) -> list.
>
> erlc t.erl:
>     t.erl:9: type tuple() already defined
>
> why should the tuple() type throw an error when the others do not?

because it is already defined.



More information about the erlang-questions mailing list