Skip to content

Commit 52b1b1d

Browse files
committed
clean up
1 parent 4765162 commit 52b1b1d

10 files changed

+57
-49
lines changed

jscomp/frontend/bs_builtin_ppx.ml

+14-11
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,20 @@ let expr_mapper (self : mapper) (e : Parsetree.expression) =
115115
| Pexp_apply (fn, args ) ->
116116
Ast_exp_apply.app_exp_mapper e self fn args
117117
| Pexp_object {pcstr_self; pcstr_fields} ->
118-
(match Ast_attributes.process_bs e.pexp_attributes with
119-
| true, pexp_attributes
120-
->
121-
{e with
122-
pexp_desc =
123-
Ast_util.ocaml_obj_as_js_object
124-
e.pexp_loc self pcstr_self pcstr_fields;
125-
pexp_attributes
126-
}
127-
| false , _ ->
128-
default_expr_mapper self e)
118+
let pexp_attributes =
119+
match Ast_attributes.process_bs e.pexp_attributes with
120+
| true, pexp_attributes
121+
->
122+
Location.prerr_warning e.pexp_loc (Bs_ffi_warning "Here @bs attribute not needed any more");
123+
pexp_attributes
124+
| false, e -> e in
125+
{e with
126+
pexp_desc =
127+
Ast_util.ocaml_obj_as_js_object
128+
e.pexp_loc self pcstr_self pcstr_fields;
129+
pexp_attributes
130+
}
131+
129132
| Pexp_match(b,
130133
[
131134
{pc_lhs= {ppat_desc = Ppat_construct ({txt = Lident "true"},None)};pc_guard=None;pc_rhs=t_exp};

jscomp/test/arity_ml.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[@@@warning "A-61-42-40"]
2-
let o = object [@bs]
2+
let o = object
33
method hi x y = x + y
44
end
55
(* Error (warning 61): This primitive declaration uses type Js_OO.Callback.arity3, which is unannotated and

jscomp/test/ffi_js_test.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let same_type =
3737
[string_config ; [%obj{hi = 3 ; low = "32"}]]
3838
)
3939

40-
let v_obj = object method hi__x () = Js.log "hei" end [@bs]
40+
let v_obj = object method hi__x () = Js.log "hei" end
4141

4242

4343
let () =

jscomp/test/gpr_627_test.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let eq loc (x, y) =
88

99
let u = object
1010
method say x y = x + y
11-
end [@bs]
11+
end
1212

1313
let v =
1414
let x = 3. in
@@ -18,7 +18,7 @@ let v =
1818
self##say u##x +. y +.x
1919
method say = fun x -> x *. self## x ()
2020
method x () = x
21-
end [@bs]
21+
end
2222

2323

2424
let () =

jscomp/test/mutable_uncurry_test.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let eq2 =fun [@bs] x {contents = y} -> x.contents = y
1313
;; eqs __LOC__ false (eq (ref 1) (ref 2) [@bs])
1414
;; eqs __LOC__ true (eq (ref 2) (ref 2) [@bs])
1515

16-
let u = object [@bs]
16+
let u = object
1717
method hi {contents = x} {contents = y} =
1818
(x : int) = y
1919
end;;

jscomp/test/ppx_this_obj_field.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let v5 =
2020
method private bark () =
2121
Js.log "bark"
2222
method xz () = 3
23-
end [@bs]
23+
end
2424

2525
let v =
2626
object(self)
@@ -44,15 +44,15 @@ let v =
4444
*)
4545
method getY () = self##y
4646
method say () = self##x + self##y
47-
end[@bs]
47+
end
4848

4949

5050
let u =
5151
object (self)
5252
method incr () = Js.log "hey"
5353
method getY () = 3
5454
method say () = 7
55-
end [@bs]
55+
end
5656

5757
let test_type = [u ; v]
5858

@@ -61,7 +61,7 @@ let z : < getX : (unit -> int [@bs.meth]); setX : (int -> unit [@bs.meth]) > =
6161
val x = ref 3
6262
method setX x = self##x := x
6363
method getX () = ! (self##x)
64-
end [@bs]
64+
end
6565

6666
let eventObj : <
6767
empty : (unit -> unit [@bs.meth]);
@@ -76,15 +76,15 @@ let eventObj : <
7676
method push a = (Js.Vector.pushBack a (self##events) : unit )
7777
method needRebuild () = Array.length self##events <> 0
7878
(* method currentEvents () = self##events *)
79-
end [@bs]
79+
end
8080

8181
let test__ x = eventObj##push x
8282
let zz : < getX : (unit -> int [@bs.meth]); setX : (int -> unit [@bs.meth]) > =
8383
object (self)
8484
val mutable x = 3
8585
method setX x = self##x #= x
8686
method getX () = (self##x)
87-
end [@bs]
87+
end
8888

8989
let test_type2 = [z;zz]
9090

jscomp/test/ppx_this_obj_test.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let v =
1111
method x () = x
1212
method say x = x *. self## x ()
1313
method hi x y = self##say x +. y
14-
end [@bs]
14+
end
1515
(** compile infer
1616
class type js_obj = object
1717
method x : unit -> float
@@ -27,7 +27,7 @@ let v2 =
2727
method hi x = fun y -> self##say x +. y
2828
method say = fun x -> x *. self## x ()
2929
method x () = x
30-
end [@bs]
30+
end
3131

3232

3333
let v3 =
@@ -38,14 +38,14 @@ let v3 =
3838
self##say u##x +. y +.x
3939
method say = fun x -> x *. self## x ()
4040
method x () = x
41-
end [@bs]
41+
end
4242

4343
let v4 =
4444
object
4545
method hi x y = x +. y
4646
method say x = x
4747
method x () = 1.
48-
end [@bs]
48+
end
4949

5050
(* let v5 = *)
5151
(* object *)

jscomp/test/reasonReact.re

-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ let convertPropsIfTheyreFromJs = (props, jsPropsToReason, debugName) => {
190190
let createClass =
191191
(type reasonState, type retainedProps, type action, debugName): reactClass =>
192192
ReasonReactOptimizedCreateClass.createClass(.
193-
[@bs]
194193
{
195194
/***
196195
* TODO: Null out fields that aren't overridden beyond defaults in

lib/4.06.1/unstable/js_compiler.ml

+14-11
Original file line numberDiff line numberDiff line change
@@ -405958,17 +405958,20 @@ let expr_mapper (self : mapper) (e : Parsetree.expression) =
405958405958
| Pexp_apply (fn, args ) ->
405959405959
Ast_exp_apply.app_exp_mapper e self fn args
405960405960
| Pexp_object {pcstr_self; pcstr_fields} ->
405961-
(match Ast_attributes.process_bs e.pexp_attributes with
405962-
| true, pexp_attributes
405963-
->
405964-
{e with
405965-
pexp_desc =
405966-
Ast_util.ocaml_obj_as_js_object
405967-
e.pexp_loc self pcstr_self pcstr_fields;
405968-
pexp_attributes
405969-
}
405970-
| false , _ ->
405971-
default_expr_mapper self e)
405961+
let pexp_attributes =
405962+
match Ast_attributes.process_bs e.pexp_attributes with
405963+
| true, pexp_attributes
405964+
->
405965+
Location.prerr_warning e.pexp_loc (Bs_ffi_warning "Here @bs attribute not needed any more");
405966+
pexp_attributes
405967+
| false, e -> e in
405968+
{e with
405969+
pexp_desc =
405970+
Ast_util.ocaml_obj_as_js_object
405971+
e.pexp_loc self pcstr_self pcstr_fields;
405972+
pexp_attributes
405973+
}
405974+
405972405975
| Pexp_match(b,
405973405976
[
405974405977
{pc_lhs= {ppat_desc = Ppat_construct ({txt = Lident "true"},None)};pc_guard=None;pc_rhs=t_exp};

lib/4.06.1/whole_compiler.ml

+14-11
Original file line numberDiff line numberDiff line change
@@ -409044,17 +409044,20 @@ let expr_mapper (self : mapper) (e : Parsetree.expression) =
409044409044
| Pexp_apply (fn, args ) ->
409045409045
Ast_exp_apply.app_exp_mapper e self fn args
409046409046
| Pexp_object {pcstr_self; pcstr_fields} ->
409047-
(match Ast_attributes.process_bs e.pexp_attributes with
409048-
| true, pexp_attributes
409049-
->
409050-
{e with
409051-
pexp_desc =
409052-
Ast_util.ocaml_obj_as_js_object
409053-
e.pexp_loc self pcstr_self pcstr_fields;
409054-
pexp_attributes
409055-
}
409056-
| false , _ ->
409057-
default_expr_mapper self e)
409047+
let pexp_attributes =
409048+
match Ast_attributes.process_bs e.pexp_attributes with
409049+
| true, pexp_attributes
409050+
->
409051+
Location.prerr_warning e.pexp_loc (Bs_ffi_warning "Here @bs attribute not needed any more");
409052+
pexp_attributes
409053+
| false, e -> e in
409054+
{e with
409055+
pexp_desc =
409056+
Ast_util.ocaml_obj_as_js_object
409057+
e.pexp_loc self pcstr_self pcstr_fields;
409058+
pexp_attributes
409059+
}
409060+
409058409061
| Pexp_match(b,
409059409062
[
409060409063
{pc_lhs= {ppat_desc = Ppat_construct ({txt = Lident "true"},None)};pc_guard=None;pc_rhs=t_exp};

0 commit comments

Comments
 (0)