sile/erl_ast

Empty map not read from ETF

alanz opened this issue · 0 comments

alanz commented

The module

-module(foo).
guard3(A) when is_map(A#{}) -> A.

generates abstract forms

{attribute,1,file,{"foo.erl",1}}.
{attribute,1,module,foo}.
{function,2,guard3,1,
          [{clause,2,
                   [{var,2,'A'}],
                   [[{call,2,{atom,2,is_map},[{map,2,{var,2,'A'},[]}]}]],
                   [{var,2,'A'}]}]}.
{eof,3}.

But when trying to read this from ETF it blows up in AbstractCode::to_forms with

UnexpectedTerm(
[Unmatched
  { value: Atom(Atom { name: "map" })
  , pattern: "\"record_index\"" }
  , Unmatched
    { value: Tuple(Tuple
       { elements:
          [ Atom(Atom { name: "map" })
          , FixInteger(FixInteger { value: 2 })
          , Tuple(Tuple
            { elements:
              [ Atom(Atom { name: "var" })
              , FixInteger(FixInteger { value: 2 })
              , Atom(Atom { name: "A" })
              ]
            })
...