Skip to content

Commit cce4bed

Browse files
Fix Parmatch crash on empty record head patterns (#8246)
* Fix Parmatch crash on empty record head patterns * Simpler test
1 parent e55c5e4 commit cce4bed

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

compiler/ml/parmatch.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ let extract_fields omegas arg =
512512

513513
let all_record_args lbls =
514514
match lbls with
515+
| [] -> []
515516
| (_, {lbl_all}, _, opt) :: _ ->
516517
let t =
517518
Array.map
@@ -560,7 +561,6 @@ let all_record_args lbls =
560561
t.(lbl.lbl_pos) <- x)
561562
lbls;
562563
Array.to_list t
563-
| _ -> fatal_error "Parmatch.all_record_args"
564564

565565
(* Build argument list when p2 >= p1, where p1 is a simple pattern *)
566566
let rec simple_match_args p1 p2 =
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
4+
let match = {};
5+
6+
let emptyDictPatternShouldCompile;
7+
8+
emptyDictPatternShouldCompile = typeof match === "object" && match !== null && !Array.isArray(match);
9+
10+
export {
11+
emptyDictPatternShouldCompile,
12+
}
13+
/* emptyDictPatternShouldCompile Not a pure module */
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let emptyDictPatternShouldCompile = switch JSON.Object(dict{}) {
2+
| JSON.Object(dict{}) => true
3+
| _ => false
4+
}

0 commit comments

Comments
 (0)