[erlang-bugs] maps used as map keys crash BEAM compiler

Kostis Sagonas kostis@REDACTED
Wed Apr 2 15:57:03 CEST 2014


In playing with map support for native code we run into the following 
compiler bug (this refers to the current -- and supposedly frozen for 
17.0, but I hope bug fixes are still possible to be included to it -- 
'master' branch)

   -module(pmatch_map_key_bug).
   -export([foo/1]).

   foo(#{#{} := 42}) -> true;
   foo(_) -> false.

$ erlc pmatch_map_key_bug.erl
pmatch_map_key_bug.erl: internal error in core_module;
crash reason: function_clause

   in function  core_lib:literal_value/1
   in call from v3_core:'-pattern_map_pairs/2-anonymous-0-'/3
   in call from lists:mapfoldl/3
   in call from v3_core:pattern_map_pairs/2
   in call from v3_core:pattern/2
   in call from v3_core:'-pattern_list/2-lc$^0/1-0-'/2
   in call from v3_core:clause/2
   in call from v3_core:clauses/2


I suggest the BEAM compiler should consistently make up its mind whether 
maps are literals or not.

Kostis

PS. Thanks to @margnus1 for the original bug report.
PS2. Apologies if this ends up twice on the mailing list; sent from a 
different mail address first.



More information about the erlang-bugs mailing list