[erlang-bugs] parameterised types for orddict:is_key/1

Thorsten Schütt schuett@REDACTED
Mon Jun 1 12:35:52 CEST 2015


Hi,

did the following commit introduce a new element to the abstract representation of Erlang? Or is it the first occurrence of {var, ‘Variablename’} without a line number? All other occurrences of variables have the form {var, LineNumber, ‘Variablename’}.

Commit:
https://github.com/erlang/otp/commit/966e9e7ed0951db306c3c5dc4b1fd4c6eac25cf9

It introduces parameterised types/specs to the orddict module. I am in particular interested in the is_key/1 function. The new spec is the following:

-spec is_key(Key, Orddict) -> boolean() when
Orddict :: orddict(Key, Value :: term()).

When I look at the abstract representation of the parser, I get the following:
{type,42,'fun',
	 [{type,42,product,
                  [{var,'Key'},
                   {user_type,43,orddict,
                          [{var,43,'Key'},
                           {ann_type,43,
                            [{var,43,'Value'},
                             {type,43,term,[]}]}]}]},
                   {type,42,boolean,[]}]}

The parser substituted the Orddict variable with the constraint from the when clause. The Orddict variable disappeared and all the line numbers stayed at 43. However, the variable ‘Key’ lost its line number. Is that on purpose?

Thanks,
  Thorsten


More information about the erlang-bugs mailing list