From b9a04a6537c87a840c6bd2705938e65c9bf90148 Mon Sep 17 00:00:00 2001 From: Akos Hajdu Date: Thu, 17 Jun 2021 08:02:16 -0700 Subject: [PATCH] [erl-frontend] Validate association kind in map pattern Summary: Associations in map patterns should only be exact (`:=`). We did not validate this previously (D28832961 (https://github.com/facebook/infer/commit/65884018dc04093173ed2d741354650609eea593)), 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 (https://github.com/facebook/infer/commit/25711189a8a62adb2c30d5b625e56bd734d079fc), 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 --- infer/src/erlang/ErlangAstValidator.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/infer/src/erlang/ErlangAstValidator.ml b/infer/src/erlang/ErlangAstValidator.ml index 20793fb1d..a62947b78 100644 --- a/infer/src/erlang/ErlangAstValidator.ml +++ b/infer/src/erlang/ErlangAstValidator.ml @@ -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} ->