summaryrefslogtreecommitdiff
path: root/lambda
diff options
context:
space:
mode:
authorThomas Refis <thomas.refis@gmail.com>2020-02-20 09:52:57 +0100
committerGabriel Scherer <gabriel.scherer@gmail.com>2020-06-06 18:46:34 +0200
commitf491929b3b228472dc74fe5fe46c7d7df2bb040c (patch)
treef9aa5b4ff5cfe9a14af7e60aefca7d140df96b2a /lambda
parent30bb39d7d885c8cba041a08c70a287c8ffff0c89 (diff)
downloadocaml-f491929b3b228472dc74fe5fe46c7d7df2bb040c.tar.gz
matching: push simple types to flatten_pattern
Unfortunately since the function is exposed and used in translcore we need to keep the generic one, and introduce a flatten_simple_pattern.
Diffstat (limited to 'lambda')
-rw-r--r--lambda/matching.ml8
1 files changed, 7 insertions, 1 deletions
diff --git a/lambda/matching.ml b/lambda/matching.ml
index 413d3fa2d2..fd3d58ac83 100644
--- a/lambda/matching.ml
+++ b/lambda/matching.ml
@@ -3583,11 +3583,17 @@ let flatten_pattern size p =
| Tpat_any -> Patterns.omegas size
| _ -> raise Cannot_flatten
+let flatten_simple_pattern size (p : Simple.pattern) =
+ match p.pat_desc with
+ | `Tuple args -> args
+ | `Any -> Patterns.omegas size
+ | _ -> raise Cannot_flatten
+
let flatten_cases size cases =
List.map
(function
| (p, []), action -> (
- match flatten_pattern size (General.erase p) with
+ match flatten_simple_pattern size p with
| p :: ps -> ((p, ps), action)
| [] -> assert false
)