[erl-frontend] Validate association kind in map pattern

Summary: Associations in map patterns should only be exact (`:=`). We did not validate this previously (D28832961 (65884018dc)), because we didn't have certain AST transformation passes that would eliminate some special functions that allowed invalid association kinds (later removed by transformation). However, with D29103633 (25711189a8), we get the AST from a different source and these invalid cases are removed, so the check is added.

Reviewed By: mmarescotti

Differential Revision: D29162325

fbshipit-source-id: a47d9f05d
master
Akos Hajdu 3 years ago committed by Facebook GitHub Bot
parent 25711189a8
commit b9a04a6537

@ -29,8 +29,7 @@ let rec validate_pattern (p : Ast.expression) =
true
| Map {map; updates} ->
let validate_assoc (a : Ast.association) =
validate_pattern a.key && validate_pattern a.value
(* TODO: a.kind must be Exact, except inside ets:fun2ms or dbg:fun2ms *)
match a.kind with Exact -> validate_pattern a.key && validate_pattern a.value | _ -> false
in
is_none map && List.for_all ~f:validate_assoc updates
| Match {pattern; body} ->

Loading…
Cancel
Save