Skip to content

Commit cac99e6

Browse files
committed
add one test before changing the logic of unused attribute warning
1 parent b4c74af commit cac99e6

File tree

13 files changed

+34545
-32606
lines changed

13 files changed

+34545
-32606
lines changed

jscomp/all.depend

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ syntax/ast_utf8_string.cmx : ext/ext_utf8.cmx ext/ext_char.cmx \
177177
syntax/ast_utf8_string.cmi
178178
syntax/ast_utf8_string_interp.cmx : ext/literals.cmx ext/ext_utf8.cmx \
179179
ext/ext_string.cmx ext/ext_char.cmx common/bs_loc.cmx \
180-
syntax/ast_compatible.cmx syntax/ast_utf8_string_interp.cmi
180+
syntax/ast_utf8_string.cmx syntax/ast_compatible.cmx \
181+
syntax/ast_utf8_string_interp.cmi
181182
syntax/ast_derive_constructor.cmx :
182183
syntax/ast_derive_util.cmx : ext/ext_list.cmx syntax/ast_compatible.cmx \
183184
syntax/ast_derive_util.cmi
@@ -206,11 +207,13 @@ syntax/ast_core_type.cmx : ext/ext_list.cmx syntax/bs_syntaxerr.cmx \
206207
syntax/ast_literal.cmx syntax/ast_compatible.cmx syntax/ast_comb.cmx \
207208
syntax/ast_core_type.cmi
208209
syntax/bs_ast_invariant.cmx : ext/literals.cmx ext/hash_set_poly.cmx \
209-
ext/ext_string.cmx common/bs_warnings.cmx syntax/bs_ast_iterator.cmx \
210-
syntax/ast_core_type.cmx syntax/bs_ast_invariant.cmi
211-
syntax/ast_attributes.cmx : ext/ext_string.cmx syntax/bs_syntaxerr.cmx \
212-
syntax/bs_ast_invariant.cmx syntax/ast_payload.cmx \
213-
syntax/ast_compatible.cmx syntax/ast_attributes.cmi
210+
ext/ext_string.cmx ext/ext_list.cmx common/bs_warnings.cmx \
211+
syntax/bs_ast_iterator.cmx syntax/ast_core_type.cmx \
212+
syntax/bs_ast_invariant.cmi
213+
syntax/ast_attributes.cmx : ext/ext_string.cmx ext/ext_list.cmx \
214+
syntax/bs_syntaxerr.cmx syntax/bs_ast_invariant.cmx \
215+
syntax/ast_payload.cmx syntax/ast_compatible.cmx \
216+
syntax/ast_attributes.cmi
214217
syntax/ast_polyvar.cmx : syntax/external_arg_spec.cmx ext/ext_pervasives.cmx \
215218
ext/ext_list.cmx syntax/bs_syntaxerr.cmx syntax/ast_attributes.cmx \
216219
syntax/ast_polyvar.cmi
@@ -271,10 +274,9 @@ syntax/ast_core_type_class_type.cmx : ext/literals.cmx ext/ext_ref.cmx \
271274
ext/ext_list.cmx syntax/bs_ast_mapper.cmx syntax/ast_util.cmx \
272275
syntax/ast_literal.cmx syntax/ast_compatible.cmx syntax/ast_comb.cmx \
273276
syntax/ast_attributes.cmx syntax/ast_core_type_class_type.cmi
274-
syntax/ppx_entry.cmx : ext/string_map.cmx ext/literals.cmx \
275-
common/js_config.cmx ext/ext_string.cmx syntax/bs_ast_mapper.cmx \
276-
syntax/bs_ast_invariant.cmx syntax/ast_util.cmx \
277-
syntax/ast_utf8_string_interp.cmx syntax/ast_utf8_string.cmx \
277+
syntax/ppx_entry.cmx : ext/string_map.cmx common/js_config.cmx \
278+
ext/ext_list.cmx syntax/bs_ast_mapper.cmx syntax/bs_ast_invariant.cmx \
279+
syntax/ast_util.cmx syntax/ast_utf8_string_interp.cmx \
278280
syntax/ast_tuple_pattern_flatten.cmx syntax/ast_tdcls.cmx \
279281
syntax/ast_structure.cmx syntax/ast_primitive.cmx syntax/ast_payload.cmx \
280282
syntax/ast_literal.cmx syntax/ast_exp_extension.cmx \
@@ -482,8 +484,8 @@ core/ocaml_parse.cmx : syntax/ppx_entry.cmx common/js_config.cmx \
482484
ext/ext_path.cmx core/ocaml_parse.cmi
483485
core/lam_pointer_info.cmx : core/lam_pointer_info.cmi
484486
core/lam_tag_info.cmx :
485-
core/lam_constant.cmx : ext/literals.cmx core/lam_tag_info.cmx \
486-
core/lam_pointer_info.cmx ext/ext_string.cmx ext/ext_list.cmx \
487+
core/lam_constant.cmx : core/lam_tag_info.cmx core/lam_pointer_info.cmx \
488+
ext/ext_string.cmx ext/ext_list.cmx syntax/ast_utf8_string_interp.cmx \
487489
core/lam_constant.cmi
488490
core/js_op.cmx : core/lam_tag_info.cmx core/lam_compat.cmx
489491
core/lam_module_ident.cmx : core/js_op.cmx core/j.cmx ext/hashtbl_make.cmx \

jscomp/bin/all_ounit_tests.ml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3799,7 +3799,7 @@ val dash_nostdlib : string
37993799
val reactjs_jsx_ppx_2_exe : string
38003800
val reactjs_jsx_ppx_3_exe : string
38013801
val unescaped_j_delimiter : string
3802-
val escaped_j_delimiter : string
3802+
38033803

38043804
val unescaped_js_delimiter : string
38053805

@@ -3934,7 +3934,6 @@ let reactjs_jsx_ppx_2_exe = "reactjs_jsx_ppx_2.exe"
39343934
let reactjs_jsx_ppx_3_exe = "reactjs_jsx_ppx_3.exe"
39353935
let unescaped_j_delimiter = "j"
39363936
let unescaped_js_delimiter = "js"
3937-
let escaped_j_delimiter = "*j" (* not user level syntax allowed *)
39383937

39393938
let native = "native"
39403939
let bytecode = "bytecode"
@@ -15176,8 +15175,18 @@ type exn += Error of pos * pos * error
1517615175
val empty_segment : segment -> bool
1517715176

1517815177
val transform_test : string -> segment list
15179-
val transform_interp : Location.t -> string -> Parsetree.expression
1518015178

15179+
15180+
15181+
val transform :
15182+
Parsetree.expression ->
15183+
string ->
15184+
string ->
15185+
Parsetree.expression
15186+
15187+
val is_unicode_string :
15188+
string ->
15189+
bool
1518115190
end = struct
1518215191
#1 "ast_utf8_string_interp.ml"
1518315192
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -15566,8 +15575,9 @@ let to_string_ident : Longident.t =
1556615575
Ldot (Ldot (Lident "Js", "String"), "make")
1556715576

1556815577

15578+
let escaped_j_delimiter = "*j" (* not user level syntax allowed *)
1556915579

15570-
let escaped = Some Literals.escaped_j_delimiter
15580+
let escaped = Some escaped_j_delimiter
1557115581

1557215582
let concat_exp
1557315583
(a : Parsetree.expression)
@@ -15622,8 +15632,7 @@ let transform_interp loc s =
1562215632
let rev_segments = cxt.segments in
1562315633
match rev_segments with
1562415634
| [] ->
15625-
Ast_compatible.const_exp_string ~loc
15626-
"" ~delimiter:Literals.escaped_j_delimiter
15635+
Ast_compatible.const_exp_string ~loc "" ?delimiter:escaped
1562715636
| [ segment] ->
1562815637
aux loc segment
1562915638
| a::rest ->
@@ -15637,6 +15646,21 @@ let transform_interp loc s =
1563715646
Location.raise_errorf ~loc:(update border start pos loc )
1563815647
"%a" pp_error error
1563915648

15649+
15650+
let transform (e : Parsetree.expression) s delim : Parsetree.expression =
15651+
if Ext_string.equal delim Literals.unescaped_js_delimiter then
15652+
let js_str = Ast_utf8_string.transform e.pexp_loc s in
15653+
{ e with pexp_desc =
15654+
Pexp_constant (
15655+
15656+
Const_string
15657+
15658+
(js_str, escaped))}
15659+
else if Ext_string.equal delim Literals.unescaped_j_delimiter then
15660+
transform_interp e.pexp_loc s
15661+
else e
15662+
15663+
let is_unicode_string opt = Ext_string.equal opt escaped_j_delimiter
1564015664
end
1564115665
module Ounit_unicode_tests
1564215666
= struct

jscomp/test/.depend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ gpr_2731_test.cmj :
290290
gpr_2789_test.cmj : mt.cmj
291291
gpr_2863_test.cmj : ../others/belt.cmj
292292
gpr_2931_test.cmj : mt.cmj
293+
gpr_3142_test.cmj :
293294
gpr_405_test.cmj : gpr_405_test.cmi
294295
gpr_441.cmj :
295296
gpr_459_test.cmj : mt.cmj

jscomp/test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_
267267
unboxed_attribute_test\
268268
406_primitive_test\
269269
fun_pattern_match\
270+
gpr_3142_test\
270271
ocaml_typedtree_test
271272
# ocaml_typedtree_test is not cross version due to camlinternalFormat
272273
# bs_uncurry_test

jscomp/test/gpr_3142_test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
var Js_mapperRt = require("../../lib/js/js_mapperRt.js");
4+
5+
var jsMapperConstantArray = /* array */[
6+
/* tuple */[
7+
97,
8+
"x"
9+
],
10+
/* tuple */[
11+
98,
12+
"b"
13+
],
14+
/* tuple */[
15+
99,
16+
"c"
17+
],
18+
/* tuple */[
19+
117,
20+
"hi"
21+
]
22+
];
23+
24+
function tToJs(param) {
25+
return Js_mapperRt.binarySearch(4, param, jsMapperConstantArray);
26+
}
27+
28+
function tFromJs(param) {
29+
return Js_mapperRt.revSearch(4, jsMapperConstantArray, param);
30+
}
31+
32+
var v = tToJs;
33+
34+
var u = tFromJs;
35+
36+
exports.tToJs = tToJs;
37+
exports.tFromJs = tFromJs;
38+
exports.v = v;
39+
exports.u = u;
40+
/* No side effect */

jscomp/test/gpr_3142_test.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
type t =
4+
[ `a [@bs.as "x"]
5+
| `u [@bs.as "hi"]
6+
| `b (* [@bs.as {js|你|js} ] *)
7+
| `c (*[@bs.as {js|我|js}] *)
8+
]
9+
[@@bs.deriving jsConverter]
10+
11+
let v,u = tToJs, tFromJs

lib/bsb.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3911,7 +3911,7 @@ val dash_nostdlib : string
39113911
val reactjs_jsx_ppx_2_exe : string
39123912
val reactjs_jsx_ppx_3_exe : string
39133913
val unescaped_j_delimiter : string
3914-
val escaped_j_delimiter : string
3914+
39153915

39163916
val unescaped_js_delimiter : string
39173917

@@ -4046,7 +4046,6 @@ let reactjs_jsx_ppx_2_exe = "reactjs_jsx_ppx_2.exe"
40464046
let reactjs_jsx_ppx_3_exe = "reactjs_jsx_ppx_3.exe"
40474047
let unescaped_j_delimiter = "j"
40484048
let unescaped_js_delimiter = "js"
4049-
let escaped_j_delimiter = "*j" (* not user level syntax allowed *)
40504049

40514050
let native = "native"
40524051
let bytecode = "bytecode"

lib/bsb_helper.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,7 @@ val dash_nostdlib : string
38853885
val reactjs_jsx_ppx_2_exe : string
38863886
val reactjs_jsx_ppx_3_exe : string
38873887
val unescaped_j_delimiter : string
3888-
val escaped_j_delimiter : string
3888+
38893889

38903890
val unescaped_js_delimiter : string
38913891

@@ -4020,7 +4020,6 @@ let reactjs_jsx_ppx_2_exe = "reactjs_jsx_ppx_2.exe"
40204020
let reactjs_jsx_ppx_3_exe = "reactjs_jsx_ppx_3.exe"
40214021
let unescaped_j_delimiter = "j"
40224022
let unescaped_js_delimiter = "js"
4023-
let escaped_j_delimiter = "*j" (* not user level syntax allowed *)
40244023

40254024
let native = "native"
40264025
let bytecode = "bytecode"

lib/bsdep.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
../lib/bsdep.ml : ../vendor/ocaml/parsing/parser.ml
2323
../lib/bsdep.ml : ../vendor/ocaml/parsing/parser.mli
2424
../lib/bsdep.ml : ../vendor/ocaml/parsing/parsetree.mli
25+
../lib/bsdep.ml : ../vendor/ocaml/parsing/printast.ml
26+
../lib/bsdep.ml : ../vendor/ocaml/parsing/printast.mli
2527
../lib/bsdep.ml : ../vendor/ocaml/parsing/syntaxerr.ml
2628
../lib/bsdep.ml : ../vendor/ocaml/parsing/syntaxerr.mli
2729
../lib/bsdep.ml : ../vendor/ocaml/tools/ocamldep.ml

0 commit comments

Comments
 (0)