Skip to content

Commit 8e23273

Browse files
committed
attempt to fix #5557 #5743
1 parent 8de6f38 commit 8e23273

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

jscomp/ml/parmatch.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ let build_other_constant proj make first next p env =
10371037

10381038
let some_other_tag = "<some other tag>"
10391039

1040-
let build_other ext env = match env with
1040+
let build_other ext env : Typedtree.pattern = match env with
10411041
| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ ->
10421042
(* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *)
10431043
make_pat (Tpat_var (Ident.create "*extension*",
@@ -1079,13 +1079,19 @@ let build_other ext env = match env with
10791079
make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env)
10801080
pat other_pats
10811081
end
1082-
| ({pat_desc=(Tpat_constant (Const_int _ | Const_char _))} as p,_) :: _ ->
1082+
| ({pat_desc=(Tpat_constant (Const_int _ ))} as p,_) :: _ ->
10831083
build_other_constant
10841084
(function Tpat_constant(Const_int i) -> i
1085-
| Tpat_constant (Const_char i) -> Char.code i
10861085
| _ -> assert false)
10871086
(function i -> Tpat_constant(Const_int i))
10881087
0 succ p env
1088+
| ({pat_desc=(Tpat_constant (Const_char _ ))} as p,_) :: _ ->
1089+
build_other_constant
1090+
(function
1091+
| Tpat_constant (Const_char i) -> Char.code i
1092+
| _ -> assert false)
1093+
(function i -> Tpat_constant(Const_char (Obj.magic (i:int) : char)))
1094+
0 succ p env
10891095
| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ ->
10901096
build_other_constant
10911097
(function Tpat_constant(Const_int32 i) -> i | _ -> assert false)

jscomp/test/build.ninja

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

jscomp/test/gpr_5557.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
4+
function isA(c) {
5+
return true;
6+
}
7+
8+
var h = /* 'a' */97;
9+
10+
exports.isA = isA;
11+
exports.h = h;
12+
/* No side effect */

jscomp/test/gpr_5557.res

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let isA = c =>
2+
switch c {
3+
| 'a' => true
4+
}
5+
6+
let h : int = ('a' :> int)

0 commit comments

Comments
 (0)