Skip to content

Commit 4d306ff

Browse files
authored
Merge pull request #2627 from BuckleScript/fix_2352
fix #2352
2 parents a428630 + e45ab51 commit 4d306ff

17 files changed

+97
-73
lines changed

jscomp/core/bs_conditional_initial.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
let setup_env () =
2727
#if BS_DEBUG then
28-
Js_config.set_debug_file "gpr_2608_test.ml";
28+
Js_config.set_debug_file "gpr_2352_test.ml";
2929
#end
3030
Lexer.replace_directive_bool "BS" true;
3131
Lexer.replace_directive_string "BS_VERSION" Bs_version.version

jscomp/core/lam_compile.ml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -832,37 +832,35 @@ and
832832
args = [obj]} as fn;
833833
arg]
834834
->
835-
begin
836-
let obj_block =
837-
compile_lambda {cxt with st = NeedValue; should_return = ReturnFalse} obj
838-
in
839-
let value_block =
840-
compile_lambda {cxt with st = NeedValue; should_return = ReturnFalse} arg
841-
in
842-
let cont block0 block1 obj_code =
835+
begin
836+
let need_value_no_return_cxt = {cxt with st = NeedValue; should_return = ReturnFalse} in
837+
let obj_output = compile_lambda need_value_no_return_cxt obj in
838+
let arg_output = compile_lambda need_value_no_return_cxt arg in
839+
let cont obj_block arg_block obj_code =
843840
Js_output.output_of_block_and_expression st should_return lam
844841
(
845842
match obj_code with
846-
| None -> Ext_list.append block0 block1
847-
| Some obj_code -> Ext_list.append block0 @@ obj_code :: block1
843+
| None -> Ext_list.append obj_block arg_block
844+
| Some obj_code -> Ext_list.append obj_block (obj_code :: arg_block)
848845
)
849846
in
850-
match obj_block, value_block with
851-
| {block = block0; value = Some obj },
852-
{block = block1; value = Some value}
847+
match obj_output, arg_output with
848+
| {block = obj_block; value = Some obj },
849+
{block = arg_block; value = Some value}
853850
->
854851
if Ext_string.ends_with method_name Literals.setter_suffix then
855852
let property =
856-
Lam_methname.translate ~loc @@
857-
String.sub method_name 0
858-
(String.length method_name - Literals.setter_suffix_len) in
853+
Lam_methname.translate ~loc
854+
(String.sub method_name 0
855+
(String.length method_name - Literals.setter_suffix_len)) in
859856
match Js_ast_util.named_expression obj with
860857
| None ->
861-
cont block0 block1 None (E.assign (E.dot obj property) value)
858+
cont obj_block arg_block None
859+
(E.seq (E.assign (E.dot obj property) value) E.unit)
862860
| Some (obj_code, obj)
863861
->
864-
cont block0 block1 (Some obj_code)
865-
(E.assign (E.dot (E.var obj) property) value)
862+
cont obj_block arg_block (Some obj_code)
863+
(E.seq (E.assign (E.dot (E.var obj) property) value) E.unit)
866864
else
867865
compile_lambda cxt
868866
(Lam.apply fn [arg]

jscomp/test/.depend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ gpr_1943_test.cmj : mt.cmj
301301
gpr_1946_test.cmj : ../stdlib/obj.cmj ../runtime/js.cmj
302302
gpr_2250_test.cmj : mt.cmj
303303
gpr_2316_test.cmj : mt.cmj ../runtime/js.cmj
304+
gpr_2352_test.cmj :
304305
gpr_2474.cmj :
305306
gpr_2487.cmj : ../others/belt.cmj
306307
gpr_2503_test.cmj : mt.cmj ../runtime/js.cmj

jscomp/test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_
243243
block_alias_test\
244244
gpr_2608_test\
245245
pipe_syntax\
246+
gpr_2352_test\
246247
# bs_uncurry_test
247248
# needs Lam to get rid of Uncurry arity first
248249
# simple_derive_test

jscomp/test/chain_code_test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ function f4(h, x, y) {
4141
x,
4242
y
4343
];
44-
return h.paint.draw = /* tuple */[
45-
x,
46-
y
47-
];
44+
h.paint.draw = /* tuple */[
45+
x,
46+
y
47+
];
48+
return /* () */0;
4849
}
4950

5051
eq("File \"chain_code_test.ml\", line 28, characters 5-12", 32, ({

jscomp/test/class_setter_getter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33

44
function fff(x) {
5-
return x.height = 2;
5+
x.height = 2;
6+
return /* () */0;
67
}
78

89
function ff(x, z) {

jscomp/test/class_type_ffi_test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function sum_poly(zero, add, arr) {
2727
}
2828

2929
function test_set(x) {
30-
return x.length = 3;
30+
x.length = 3;
31+
return /* () */0;
3132
}
3233

3334
function f(x) {

jscomp/test/demo.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,22 @@ function ui_layout(compile, lookup, appContext) {
102102
}
103103
}));
104104
Runtime.setInterval((function () {
105-
return grid.dataSource = Array.prototype.map.call(data, (function (param) {
106-
var price = param[/* price */1];
107-
var bid = price + 20 * Math.random();
108-
var ask = price + 20 * Math.random();
109-
var result = Curry._1(computeFunction[0], {
110-
bid: bid,
111-
ask: ask
112-
});
113-
return /* array */[
114-
mk_titleRow(param[/* ticker */0]),
115-
mk_titleRow(bid.toFixed(2)),
116-
mk_titleRow(ask.toFixed(2)),
117-
mk_titleRow(result.toFixed(2))
118-
];
119-
}));
105+
grid.dataSource = Array.prototype.map.call(data, (function (param) {
106+
var price = param[/* price */1];
107+
var bid = price + 20 * Math.random();
108+
var ask = price + 20 * Math.random();
109+
var result = Curry._1(computeFunction[0], {
110+
bid: bid,
111+
ask: ask
112+
});
113+
return /* array */[
114+
mk_titleRow(param[/* ticker */0]),
115+
mk_titleRow(bid.toFixed(2)),
116+
mk_titleRow(ask.toFixed(2)),
117+
mk_titleRow(result.toFixed(2))
118+
];
119+
}));
120+
return /* () */0;
120121
}), 100);
121122
return hw1;
122123
}

jscomp/test/gpr_2352_test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
4+
function f(x) {
5+
x.hey = 22;
6+
return /* () */0;
7+
}
8+
9+
exports.f = f;
10+
/* No side effect */

jscomp/test/gpr_2352_test.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
let f x =
4+
x##hey#= 22

0 commit comments

Comments
 (0)