File tree Expand file tree Collapse file tree 6 files changed +82
-11
lines changed Expand file tree Collapse file tree 6 files changed +82
-11
lines changed Original file line number Diff line number Diff line change @@ -374,17 +374,25 @@ let rec pp_function method_
374
374
formal_parameter_list inner_cxt f (List. tl l) env )
375
375
in
376
376
P. space f ;
377
- ignore @@ P. brace_vgroup f 1 (fun _ ->
378
- P. string f L. var ;
379
- P. space f;
380
- let cxt = ident cxt f (List. hd l) in
381
- P. space f ;
382
- P. string f L. eq ;
383
- P. space f ;
384
- P. string f L. this;
385
- P. space f ;
386
- semi f ;
387
- P. newline f ;
377
+ ignore @@ P. brace_vgroup f 1 (fun _ ->
378
+ let cxt =
379
+ if not (Js_fun_env. get_unused env 0 ) then
380
+ begin
381
+ P. string f L. var ;
382
+ P. space f;
383
+ let cxt = ident cxt f (List. hd l) in
384
+ P. space f ;
385
+ P. string f L. eq ;
386
+ P. space f ;
387
+ P. string f L. this;
388
+ P. space f ;
389
+ semi f ;
390
+ P. newline f ;
391
+ cxt ;
392
+ end
393
+ else
394
+ cxt
395
+ in
388
396
statement_list false cxt f b
389
397
);
390
398
Original file line number Diff line number Diff line change @@ -774,6 +774,8 @@ undef_regression_test.cmj : ../runtime/js_obj.cmj ../runtime/js.cmj
774
774
undef_regression_test.cmx : ../runtime/js_obj.cmx ../runtime/js.cmx
775
775
unitest_string.cmj :
776
776
unitest_string.cmx :
777
+ unsafe_obj_external.cmj : ../runtime/js.cmj
778
+ unsafe_obj_external.cmx : ../runtime/js.cmx
777
779
unsafe_ppx_test.cmj : mt.cmi ffi_js.cmj
778
780
unsafe_ppx_test.cmx : mt.cmx ffi_js.cmx
779
781
unsafe_this.cmj : ../runtime/js.cmj unsafe_this.cmi
@@ -1520,6 +1522,8 @@ undef_regression_test.cmo : ../runtime/js_obj.cmo ../runtime/js.cmo
1520
1522
undef_regression_test.cmj : ../runtime/js_obj.cmj ../runtime/js.cmj
1521
1523
unitest_string.cmo :
1522
1524
unitest_string.cmj :
1525
+ unsafe_obj_external.cmo : ../runtime/js.cmo
1526
+ unsafe_obj_external.cmj : ../runtime/js.cmj
1523
1527
unsafe_ppx_test.cmo : mt.cmi ffi_js.cmo
1524
1528
unsafe_ppx_test.cmj : mt.cmj ffi_js.cmj
1525
1529
unsafe_this.cmo : ../runtime/js.cmo unsafe_this.cmi
Original file line number Diff line number Diff line change @@ -46,9 +46,14 @@ function f(x) {
46
46
} ) ;
47
47
}
48
48
49
+ function u ( ) {
50
+ return x ;
51
+ }
52
+
49
53
exports . uux_this = uux_this ;
50
54
exports . even = even ;
51
55
exports . bark = bark ;
52
56
exports . js_obj = js_obj ;
53
57
exports . f = f ;
58
+ exports . u = u ;
54
59
/* uux_this Not a pure module */
Original file line number Diff line number Diff line change @@ -39,3 +39,4 @@ let f (x : x ) =
39
39
end
40
40
end
41
41
42
+ let u = fun [@bs .this ] (_ : int ) (x : int ) -> x
Original file line number Diff line number Diff line change
1
+ // GENERATED CODE BY BUCKLESCRIPT VERSION 0.9.0 , PLEASE EDIT WITH CARE
2
+ 'use strict' ;
3
+
4
+
5
+ var v = {
6
+ x : function ( ) {
7
+ return 3 ;
8
+ } ,
9
+ say : function ( x ) {
10
+ var self = this ;
11
+ return self . x ( ) + x | 0 ;
12
+ }
13
+ } ;
14
+
15
+ var u = v . x ( ) + v . say ( 3 ) | 0 ;
16
+
17
+ exports . v = v ;
18
+ exports . u = u ;
19
+ /* v Not a pure module */
Original file line number Diff line number Diff line change
1
+
2
+
3
+
4
+ external config :
5
+ x : ('self_type -> 'x [@ bs.this]) ->
6
+ say :('self_type -> 'x -> 'say [@ bs.this]) ->
7
+ unit ->
8
+ (<
9
+ x : unit -> 'x [@ bs.meth];
10
+ say : 'x -> 'say [@ bs.meth]
11
+ > Js .t as 'self_type ) = " " [@@ bs.obj]
12
+
13
+
14
+ let v =
15
+ let x = 3 in
16
+ config
17
+ ~x: (fun [@bs .this ] _ -> x )
18
+ ~say: (fun [@bs .this ] self x -> self##x () + x)
19
+ ()
20
+
21
+ (* *
22
+ let x = 3 in
23
+ object (self : 'self_type)
24
+ method x = x
25
+ method say x = self##x + x
26
+ end [@bs]
27
+ *)
28
+ let u =
29
+ v##x () + v##say 3
30
+
31
+
32
+ (* local variables: *)
33
+ (* compile-command: "bsc -I ../runtime -drawlambda unsafe_obj_external.ml" *)
34
+ (* end: *)
You can’t perform that action at this time.
0 commit comments