[erlang-bugs] Internal error in v3_kernel when using funny map keys

Björn-Egil Dahlberg egil@REDACTED
Wed Mar 5 18:41:18 CET 2014


On 2014-03-04 23:39, Anthony Ramine wrote:
> I would vote for limiting it to only literals in Erlang then, it makes the limitation clearer and that would make sure we avoid writing stuff we are not supposed to yet, right?
>
I think this has to be both in erl_lint and in v3_kernel. Informally ..

erl_lint should take care of the following:
* only values, i.e.  atomics + maps + cons + tuples + binaries
* deny all variables in those values
* deny all other expressions. i.e expressions that needs evaluation to 
become values

Now, binaries are a bit trickier. Even though you may write some 
binaries as literals the compiler could deny this if it becomes to big.
For instance:

t1() -> <<0:256>>.
becomes:
{move,{literal,<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>},{x,0}}.

and
t2() -> <<0:257>>.
becomes:
{bs_init_bits,{f,0},257,0,0,{field_flags,[]},{x,0}}.
{bs_put_integer,{f,0},{integer,257},1,{field_flags,[unsigned,big]},{integer,0}}.

So we have to deny those as well because kernel *has* to have literals. 
I believe it is easiest to deny these kinds in v3_kernel.
Maps does not have literals yet (I have a branch for it but will wait a 
bit before introducing it .. because pull-requests) so those must be 
denied as well.

These are two different kinds of problems:
1) For 17.0 only literal keys (values) should be valid in the language 
-> checked in erl_lint
2) Limitations where the compiler refuses or don't know how to produce 
literals -> v3_kernel (or earlier if suitable place is found).

What do you think?

// Björn-Egil



More information about the erlang-bugs mailing list