Skip to content

Commit 606719f

Browse files
committedDec 5, 2024·
Fix change to test.
1 parent d41591c commit 606719f

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed
 

‎compiler/ml/ctype.ml

+1
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,7 @@ and mcomp_record_description type_pairs env =
20462046
if
20472047
Ident.name l1.ld_id = Ident.name l2.ld_id
20482048
&& l1.ld_mutable = l2.ld_mutable
2049+
&& l1.ld_optional = l2.ld_optional
20492050
then iter xs ys
20502051
else raise (Unify [])
20512052
| [], [] -> ()

‎compiler/ml/parmatch.ml

+7-2
Original file line numberDiff line numberDiff line change
@@ -526,19 +526,24 @@ let all_record_args lbls =
526526
in
527527
List.iter
528528
(fun ((id, lbl, pat) as x) ->
529+
let lbl_is_optional () =
530+
match lbl.lbl_repres with
531+
| Record_inlined _ -> false
532+
| _ -> lbl.lbl_optional
533+
in
529534
let x =
530535
match pat.pat_desc with
531536
| Tpat_construct
532537
( {txt = Longident.Ldot (Longident.Lident "*predef*", "Some")},
533538
_,
534539
[({pat_desc = Tpat_constant _} as c)] )
535-
when lbl.lbl_optional ->
540+
when lbl_is_optional () ->
536541
(id, lbl, c)
537542
| Tpat_construct
538543
( {txt = Longident.Ldot (Longident.Lident "*predef*", "Some")},
539544
_,
540545
[({pat_desc = Tpat_construct (_, cd, _)} as pat_construct)] )
541-
when lbl.lbl_optional -> (
546+
when lbl_is_optional () -> (
542547
let cdecl =
543548
Ast_untagged_variants
544549
.constructor_declaration_from_constructor_description

‎tests/tests/src/record_regression.mjs

+29-17
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,36 @@ function inlinedRecord(ir) {
172172
let x1 = ir.x1;
173173
let x0 = ir.x0;
174174
if (x1 !== undefined) {
175-
if (x1 === "x1") {
176-
let x2 = ir.x2;
177-
if (x2 !== undefined) {
178-
return [
179-
x0,
180-
"x1",
181-
x2,
182-
ir.x3
183-
];
184-
}
185-
175+
switch (x1) {
176+
case "x1" :
177+
let x2 = ir.x2;
178+
if (x2 !== undefined) {
179+
return [
180+
x0,
181+
"x1",
182+
x2,
183+
ir.x3
184+
];
185+
}
186+
break;
187+
case "xx1" :
188+
let x2$1 = ir.x2;
189+
if (x2$1 !== undefined) {
190+
return [
191+
x0,
192+
"xx1",
193+
x2$1,
194+
ir.x3
195+
];
196+
}
197+
break;
186198
}
187-
let x2$1 = ir.x2;
188-
if (x2$1 !== undefined) {
199+
let x2$2 = ir.x2;
200+
if (x2$2 !== undefined) {
189201
return [
190202
x0,
191203
x1,
192-
x2$1,
204+
x2$2,
193205
ir.x3
194206
];
195207
} else {
@@ -201,12 +213,12 @@ function inlinedRecord(ir) {
201213
];
202214
}
203215
}
204-
let x2$2 = ir.x2;
205-
if (x2$2 !== undefined) {
216+
let x2$3 = ir.x2;
217+
if (x2$3 !== undefined) {
206218
return [
207219
x0,
208220
"n/a",
209-
x2$2,
221+
x2$3,
210222
ir.x3
211223
];
212224
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.