Skip to content

Commit 3c82306

Browse files
committed
refactor
1 parent 4675cc1 commit 3c82306

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

jscomp/ml/typecore.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ let build_or_pat_for_variant_spread env loc lid expected_ty =
601601
match decl with
602602
| {type_kind = Type_variant constructors; type_params} -> (
603603
if List.length type_params > 0 then raise (Error (lid.loc, env, Type_params_not_supported lid.txt));
604-
let ty = newty (Tconstr (path, [], ref Mnil)) in
604+
let ty = newgenty (Tconstr (path, [], ref Mnil)) in
605605
(try
606606
Ctype.subtype env ty expected_ty ()
607607
with
@@ -617,7 +617,7 @@ let build_or_pat_for_variant_spread env loc lid expected_ty =
617617
{
618618
pat_desc =
619619
Tpat_construct
620-
( {loc = Location.none; txt = lid},
620+
( {loc = c.cd_loc; txt = lid},
621621
Env.lookup_constructor ~loc:c.cd_loc lid env,
622622
match c.cd_args with
623623
| Cstr_tuple [] -> []
@@ -637,7 +637,8 @@ let build_or_pat_for_variant_spread env loc lid expected_ty =
637637
pat_type = expected_ty;
638638
pat_env = env;
639639
pat_attributes = [];
640-
})
640+
})
641+
|> List.rev
641642
in
642643
match pats with
643644
| [] -> raise (Error (lid.loc, env, Not_a_variant_type lid.txt))
@@ -646,7 +647,7 @@ let build_or_pat_for_variant_spread env loc lid expected_ty =
646647
List.fold_left
647648
(fun pat pat0 ->
648649
{
649-
Typedtree.pat_desc = Tpat_or (pat0, pat, None);
650+
Typedtree.pat_desc = Tpat_or (pat, pat0, None);
650651
pat_extra = [];
651652
pat_loc = gloc;
652653
pat_env = env;

0 commit comments

Comments
 (0)