Skip to content

Commit 183e81e

Browse files
bobzhangbutterunderflow
authored andcommitted
add a test case snapshot
1 parent 32a133d commit 183e81e

File tree

8 files changed

+394
-494
lines changed

8 files changed

+394
-494
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: 5 additions & 0 deletions
Large diffs are not rendered by default.

jscomp/test/gpr_5557.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
4+
function isA(c) {
5+
if (c === 97) {
6+
return true;
7+
}
8+
throw {
9+
RE_EXN_ID: "Match_failure",
10+
_1: [
11+
"gpr_5557.res",
12+
5,
13+
2
14+
],
15+
Error: new Error()
16+
};
17+
}
18+
19+
var h = /* 'a' */97;
20+
21+
exports.isA = isA;
22+
exports.h = h;
23+
/* No side effect */

jscomp/test/gpr_5557.res

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

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 10 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -27497,7 +27497,7 @@ let build_other_constant proj make first next p env =
2749727497

2749827498
let some_other_tag = "<some other tag>"
2749927499

27500-
let build_other ext env = match env with
27500+
let build_other ext env : Typedtree.pattern = match env with
2750127501
| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ ->
2750227502
(* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *)
2750327503
make_pat (Tpat_var (Ident.create "*extension*",
@@ -27539,13 +27539,19 @@ let build_other ext env = match env with
2753927539
make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env)
2754027540
pat other_pats
2754127541
end
27542-
| ({pat_desc=(Tpat_constant (Const_int _ | Const_char _))} as p,_) :: _ ->
27542+
| ({pat_desc=(Tpat_constant (Const_int _ ))} as p,_) :: _ ->
2754327543
build_other_constant
2754427544
(function Tpat_constant(Const_int i) -> i
27545-
| Tpat_constant (Const_char i) -> Char.code i
2754627545
| _ -> assert false)
2754727546
(function i -> Tpat_constant(Const_int i))
2754827547
0 succ p env
27548+
| ({pat_desc=(Tpat_constant (Const_char _ ))} as p,_) :: _ ->
27549+
build_other_constant
27550+
(function
27551+
| Tpat_constant (Const_char i) -> Char.code i
27552+
| _ -> assert false)
27553+
(function i -> Tpat_constant(Const_char (Obj.magic (i:int) : char)))
27554+
0 succ p env
2754927555
| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ ->
2755027556
build_other_constant
2755127557
(function Tpat_constant(Const_int32 i) -> i | _ -> assert false)
@@ -51121,165 +51127,6 @@ let isKeywordTxt str =
5112151127

5112251128
let catch = Lident "catch"
5112351129

51124-
end
51125-
module Res_utf8 : sig
51126-
#1 "res_utf8.mli"
51127-
val repl : int
51128-
51129-
val max : int
51130-
51131-
val decodeCodePoint : int -> string -> int -> int * int
51132-
51133-
val encodeCodePoint : int -> string
51134-
51135-
val isValidCodePoint : int -> bool
51136-
51137-
end = struct
51138-
#1 "res_utf8.ml"
51139-
(* https://tools.ietf.org/html/rfc3629#section-10 *)
51140-
(* let bom = 0xFEFF *)
51141-
51142-
let repl = 0xFFFD
51143-
51144-
(* let min = 0x0000 *)
51145-
let max = 0x10FFFF
51146-
51147-
let surrogateMin = 0xD800
51148-
let surrogateMax = 0xDFFF
51149-
51150-
(*
51151-
* Char. number range | UTF-8 octet sequence
51152-
* (hexadecimal) | (binary)
51153-
* --------------------+---------------------------------------------
51154-
* 0000 0000-0000 007F | 0xxxxxxx
51155-
* 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
51156-
* 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
51157-
* 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
51158-
*)
51159-
let h2 = 0b1100_0000
51160-
let h3 = 0b1110_0000
51161-
let h4 = 0b1111_0000
51162-
51163-
let cont_mask = 0b0011_1111
51164-
51165-
type category = {low: int; high: int; size: int}
51166-
51167-
let locb = 0b1000_0000
51168-
let hicb = 0b1011_1111
51169-
51170-
let categoryTable = [|
51171-
(* 0 *) {low = -1; high= -1; size= 1}; (* invalid *)
51172-
(* 1 *) {low = 1; high= -1; size= 1}; (* ascii *)
51173-
(* 2 *) {low = locb; high= hicb; size= 2};
51174-
(* 3 *) {low = 0xA0; high= hicb; size= 3};
51175-
(* 4 *) {low = locb; high= hicb; size= 3};
51176-
(* 5 *) {low = locb; high= 0x9F; size= 3};
51177-
(* 6 *) {low = 0x90; high= hicb; size= 4};
51178-
(* 7 *) {low = locb; high= hicb; size= 4};
51179-
(* 8 *) {low = locb; high= 0x8F; size= 4};
51180-
|] [@@ocamlformat "disable"]
51181-
51182-
let categories = [|
51183-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51184-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51185-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51186-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51187-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51188-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51189-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51190-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51191-
51192-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51193-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51194-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51195-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51196-
(* surrogate range U+D800 - U+DFFFF = 55296 - 917503 *)
51197-
0; 0; 2; 2;2; 2; 2; 2;2; 2; 2; 2;2; 2; 2; 2;
51198-
2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2;
51199-
3; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 5; 4; 4;
51200-
6; 7; 7 ;7; 8; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0;
51201-
|] [@@ocamlformat "disable"]
51202-
51203-
let decodeCodePoint i s len =
51204-
if len < 1 then (repl, 1)
51205-
else
51206-
let first = int_of_char (String.unsafe_get s i) in
51207-
if first < 128 then (first, 1)
51208-
else
51209-
let index = Array.unsafe_get categories first in
51210-
if index = 0 then (repl, 1)
51211-
else
51212-
let cat = Array.unsafe_get categoryTable index in
51213-
if len < i + cat.size then (repl, 1)
51214-
else if cat.size == 2 then
51215-
let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51216-
if c1 < cat.low || cat.high < c1 then (repl, 1)
51217-
else
51218-
let i1 = c1 land 0b00111111 in
51219-
let i0 = (first land 0b00011111) lsl 6 in
51220-
let uc = i0 lor i1 in
51221-
(uc, 2)
51222-
else if cat.size == 3 then
51223-
let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51224-
let c2 = int_of_char (String.unsafe_get s (i + 2)) in
51225-
if c1 < cat.low || cat.high < c1 || c2 < locb || hicb < c2 then
51226-
(repl, 1)
51227-
else
51228-
let i0 = (first land 0b00001111) lsl 12 in
51229-
let i1 = (c1 land 0b00111111) lsl 6 in
51230-
let i2 = c2 land 0b00111111 in
51231-
let uc = i0 lor i1 lor i2 in
51232-
(uc, 3)
51233-
else
51234-
let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51235-
let c2 = int_of_char (String.unsafe_get s (i + 2)) in
51236-
let c3 = int_of_char (String.unsafe_get s (i + 3)) in
51237-
if
51238-
c1 < cat.low || cat.high < c1 || c2 < locb || hicb < c2 || c3 < locb
51239-
|| hicb < c3
51240-
then (repl, 1)
51241-
else
51242-
let i1 = (c1 land 0x3f) lsl 12 in
51243-
let i2 = (c2 land 0x3f) lsl 6 in
51244-
let i3 = c3 land 0x3f in
51245-
let i0 = (first land 0x07) lsl 18 in
51246-
let uc = i0 lor i3 lor i2 lor i1 in
51247-
(uc, 4)
51248-
51249-
let encodeCodePoint c =
51250-
if c <= 127 then (
51251-
let bytes = (Bytes.create [@doesNotRaise]) 1 in
51252-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr c);
51253-
Bytes.unsafe_to_string bytes)
51254-
else if c <= 2047 then (
51255-
let bytes = (Bytes.create [@doesNotRaise]) 2 in
51256-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h2 lor (c lsr 6)));
51257-
Bytes.unsafe_set bytes 1
51258-
(Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51259-
Bytes.unsafe_to_string bytes)
51260-
else if c <= 65535 then (
51261-
let bytes = (Bytes.create [@doesNotRaise]) 3 in
51262-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h3 lor (c lsr 12)));
51263-
Bytes.unsafe_set bytes 1
51264-
(Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
51265-
Bytes.unsafe_set bytes 2
51266-
(Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51267-
Bytes.unsafe_to_string bytes)
51268-
else
51269-
(* if c <= max then *)
51270-
let bytes = (Bytes.create [@doesNotRaise]) 4 in
51271-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h4 lor (c lsr 18)));
51272-
Bytes.unsafe_set bytes 1
51273-
(Char.unsafe_chr (0b1000_0000 lor ((c lsr 12) land cont_mask)));
51274-
Bytes.unsafe_set bytes 2
51275-
(Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
51276-
Bytes.unsafe_set bytes 3
51277-
(Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51278-
Bytes.unsafe_to_string bytes
51279-
51280-
let isValidCodePoint c =
51281-
(0 <= c && c < surrogateMin) || (surrogateMax < c && c <= max)
51282-
5128351130
end
5128451131
module Res_printer : sig
5128551132
#1 "res_printer.mli"
@@ -51878,7 +51725,7 @@ let printConstant ?(templateLiteral = false) c =
5187851725
let s = (Bytes.create [@doesNotRaise]) 1 in
5187951726
Bytes.unsafe_set s 0 c;
5188051727
Bytes.unsafe_to_string s
51881-
| c -> Res_utf8.encodeCodePoint (Obj.magic c)
51728+
| c -> string_of_int (Obj.magic c)
5188251729
in
5188351730
Doc.text ("'" ^ str ^ "'")
5188451731

lib/4.06.1/unstable/js_compiler.ml.d

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@
584584
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_printer.ml
585585
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_printer.mli
586586
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_token.ml
587-
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_utf8.ml
588-
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_utf8.mli
589587
../lib/4.06.1/unstable/js_compiler.ml: ./outcome_printer/outcome_printer_ns.ml
590588
../lib/4.06.1/unstable/js_compiler.ml: ./outcome_printer/outcome_printer_ns.mli
591589
../lib/4.06.1/unstable/js_compiler.ml: ./stubs/bs_hash_stubs.pp.ml

0 commit comments

Comments
 (0)