[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 4 years ago committed by Facebook GitHub Bot
parent 25711189a8
commit b9a04a6537

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

Loading…
Cancel
Save