diff --git a/jscomp/core/bs_conditional_initial.ml b/jscomp/core/bs_conditional_initial.ml index f47e718d87..46a981cd2e 100644 --- a/jscomp/core/bs_conditional_initial.ml +++ b/jscomp/core/bs_conditional_initial.ml @@ -25,7 +25,7 @@ let setup_env () = #if BS_DEBUG then - Js_config.set_debug_file "gpr_2608_test.ml"; + Js_config.set_debug_file "gpr_2352_test.ml"; #end Lexer.replace_directive_bool "BS" true; Lexer.replace_directive_string "BS_VERSION" Bs_version.version diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 97459b90dc..905e3ab89c 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -832,37 +832,35 @@ and args = [obj]} as fn; arg] -> - begin - let obj_block = - compile_lambda {cxt with st = NeedValue; should_return = ReturnFalse} obj - in - let value_block = - compile_lambda {cxt with st = NeedValue; should_return = ReturnFalse} arg - in - let cont block0 block1 obj_code = + begin + let need_value_no_return_cxt = {cxt with st = NeedValue; should_return = ReturnFalse} in + let obj_output = compile_lambda need_value_no_return_cxt obj in + let arg_output = compile_lambda need_value_no_return_cxt arg in + let cont obj_block arg_block obj_code = Js_output.output_of_block_and_expression st should_return lam ( match obj_code with - | None -> Ext_list.append block0 block1 - | Some obj_code -> Ext_list.append block0 @@ obj_code :: block1 + | None -> Ext_list.append obj_block arg_block + | Some obj_code -> Ext_list.append obj_block (obj_code :: arg_block) ) in - match obj_block, value_block with - | {block = block0; value = Some obj }, - {block = block1; value = Some value} + match obj_output, arg_output with + | {block = obj_block; value = Some obj }, + {block = arg_block; value = Some value} -> if Ext_string.ends_with method_name Literals.setter_suffix then let property = - Lam_methname.translate ~loc @@ - String.sub method_name 0 - (String.length method_name - Literals.setter_suffix_len) in + Lam_methname.translate ~loc + (String.sub method_name 0 + (String.length method_name - Literals.setter_suffix_len)) in match Js_ast_util.named_expression obj with | None -> - cont block0 block1 None (E.assign (E.dot obj property) value) + cont obj_block arg_block None + (E.seq (E.assign (E.dot obj property) value) E.unit) | Some (obj_code, obj) -> - cont block0 block1 (Some obj_code) - (E.assign (E.dot (E.var obj) property) value) + cont obj_block arg_block (Some obj_code) + (E.seq (E.assign (E.dot (E.var obj) property) value) E.unit) else compile_lambda cxt (Lam.apply fn [arg] diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 5a1fc93384..cdeb052626 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -301,6 +301,7 @@ gpr_1943_test.cmj : mt.cmj gpr_1946_test.cmj : ../stdlib/obj.cmj ../runtime/js.cmj gpr_2250_test.cmj : mt.cmj gpr_2316_test.cmj : mt.cmj ../runtime/js.cmj +gpr_2352_test.cmj : gpr_2474.cmj : gpr_2487.cmj : ../others/belt.cmj gpr_2503_test.cmj : mt.cmj ../runtime/js.cmj diff --git a/jscomp/test/Makefile b/jscomp/test/Makefile index ac3863c0fa..8b70afbddc 100644 --- a/jscomp/test/Makefile +++ b/jscomp/test/Makefile @@ -243,6 +243,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_ block_alias_test\ gpr_2608_test\ pipe_syntax\ + gpr_2352_test\ # bs_uncurry_test # needs Lam to get rid of Uncurry arity first # simple_derive_test diff --git a/jscomp/test/chain_code_test.js b/jscomp/test/chain_code_test.js index 1f760359df..c871032786 100644 --- a/jscomp/test/chain_code_test.js +++ b/jscomp/test/chain_code_test.js @@ -41,10 +41,11 @@ function f4(h, x, y) { x, y ]; - return h.paint.draw = /* tuple */[ - x, - y - ]; + h.paint.draw = /* tuple */[ + x, + y + ]; + return /* () */0; } eq("File \"chain_code_test.ml\", line 28, characters 5-12", 32, ({ diff --git a/jscomp/test/class_setter_getter.js b/jscomp/test/class_setter_getter.js index af40d13abe..1fd355bce3 100644 --- a/jscomp/test/class_setter_getter.js +++ b/jscomp/test/class_setter_getter.js @@ -2,7 +2,8 @@ function fff(x) { - return x.height = 2; + x.height = 2; + return /* () */0; } function ff(x, z) { diff --git a/jscomp/test/class_type_ffi_test.js b/jscomp/test/class_type_ffi_test.js index 02cb78ab33..63aaa43c37 100644 --- a/jscomp/test/class_type_ffi_test.js +++ b/jscomp/test/class_type_ffi_test.js @@ -27,7 +27,8 @@ function sum_poly(zero, add, arr) { } function test_set(x) { - return x.length = 3; + x.length = 3; + return /* () */0; } function f(x) { diff --git a/jscomp/test/demo.js b/jscomp/test/demo.js index 7117f94cb7..6ab1b5ebcc 100644 --- a/jscomp/test/demo.js +++ b/jscomp/test/demo.js @@ -102,21 +102,22 @@ function ui_layout(compile, lookup, appContext) { } })); Runtime.setInterval((function () { - return grid.dataSource = Array.prototype.map.call(data, (function (param) { - var price = param[/* price */1]; - var bid = price + 20 * Math.random(); - var ask = price + 20 * Math.random(); - var result = Curry._1(computeFunction[0], { - bid: bid, - ask: ask - }); - return /* array */[ - mk_titleRow(param[/* ticker */0]), - mk_titleRow(bid.toFixed(2)), - mk_titleRow(ask.toFixed(2)), - mk_titleRow(result.toFixed(2)) - ]; - })); + grid.dataSource = Array.prototype.map.call(data, (function (param) { + var price = param[/* price */1]; + var bid = price + 20 * Math.random(); + var ask = price + 20 * Math.random(); + var result = Curry._1(computeFunction[0], { + bid: bid, + ask: ask + }); + return /* array */[ + mk_titleRow(param[/* ticker */0]), + mk_titleRow(bid.toFixed(2)), + mk_titleRow(ask.toFixed(2)), + mk_titleRow(result.toFixed(2)) + ]; + })); + return /* () */0; }), 100); return hw1; } diff --git a/jscomp/test/gpr_2352_test.js b/jscomp/test/gpr_2352_test.js new file mode 100644 index 0000000000..77af4341c2 --- /dev/null +++ b/jscomp/test/gpr_2352_test.js @@ -0,0 +1,10 @@ +'use strict'; + + +function f(x) { + x.hey = 22; + return /* () */0; +} + +exports.f = f; +/* No side effect */ diff --git a/jscomp/test/gpr_2352_test.ml b/jscomp/test/gpr_2352_test.ml new file mode 100644 index 0000000000..dc1fa1b639 --- /dev/null +++ b/jscomp/test/gpr_2352_test.ml @@ -0,0 +1,4 @@ + + +let f x = + x##hey#= 22 \ No newline at end of file diff --git a/jscomp/test/local_class_type.js b/jscomp/test/local_class_type.js index ee25cf6df3..bf76e0eabc 100644 --- a/jscomp/test/local_class_type.js +++ b/jscomp/test/local_class_type.js @@ -3,7 +3,8 @@ var Caml_oo_curry = require("../../lib/js/caml_oo_curry.js"); function f(x) { - return x.height = 3; + x.height = 3; + return /* () */0; } function h(x) { diff --git a/jscomp/test/mutable_obj_test.js b/jscomp/test/mutable_obj_test.js index 8fc5108223..dd10cc3503 100644 --- a/jscomp/test/mutable_obj_test.js +++ b/jscomp/test/mutable_obj_test.js @@ -2,12 +2,13 @@ function f(x) { - return x.dec = (function (x) { - return { - x: x, - y: x - }; - }); + x.dec = (function (x) { + return { + x: x, + y: x + }; + }); + return /* () */0; } exports.f = f; diff --git a/jscomp/test/ppx_this_obj_field.js b/jscomp/test/ppx_this_obj_field.js index 3a030d2505..fee96affc4 100644 --- a/jscomp/test/ppx_this_obj_field.js +++ b/jscomp/test/ppx_this_obj_field.js @@ -59,11 +59,13 @@ var v = { y: 0, reset: (function () { var self = this ; - return self.y = 0; + self.y = 0; + return /* () */0; }), incr: (function () { var self = this ; - return self.y = self.y + 1 | 0; + self.y = self.y + 1 | 0; + return /* () */0; }), getY: (function () { var self = this ; @@ -139,7 +141,8 @@ var zz = { x: 3, setX: (function (x) { var self = this ; - return self.x = x; + self.x = x; + return /* () */0; }), getX: (function () { var self = this ; diff --git a/jscomp/test/test_case_set.js b/jscomp/test/test_case_set.js index 7844e4140b..94248a8737 100644 --- a/jscomp/test/test_case_set.js +++ b/jscomp/test/test_case_set.js @@ -3,7 +3,8 @@ var Caml_oo_curry = require("../../lib/js/caml_oo_curry.js"); function f(x) { - return x.case = 3; + x.case = 3; + return /* () */0; } function g(x) { diff --git a/jscomp/test/test_unsafe_obj_ffi.js b/jscomp/test/test_unsafe_obj_ffi.js index 276f43351f..466f80b0f8 100644 --- a/jscomp/test/test_unsafe_obj_ffi.js +++ b/jscomp/test/test_unsafe_obj_ffi.js @@ -12,7 +12,8 @@ function g(x) { function h(x) { x.height = 3; - return x.width = 3; + x.width = 3; + return /* () */0; } exports.f = f; diff --git a/jscomp/xwatcher/xwatcher_util.js b/jscomp/xwatcher/xwatcher_util.js index 1299df3758..7dd9883fb7 100644 --- a/jscomp/xwatcher/xwatcher_util.js +++ b/jscomp/xwatcher/xwatcher_util.js @@ -72,7 +72,8 @@ function makeLock() { }), release: (function () { var self = this ; - return self.isBuilding = /* false */0; + self.isBuilding = /* false */0; + return /* () */0; }) }; } diff --git a/lib/whole_compiler.ml b/lib/whole_compiler.ml index d9c008c565..32e75f3c9f 100644 --- a/lib/whole_compiler.ml +++ b/lib/whole_compiler.ml @@ -98201,37 +98201,35 @@ and args = [obj]} as fn; arg] -> - begin - let obj_block = - compile_lambda {cxt with st = NeedValue; should_return = ReturnFalse} obj - in - let value_block = - compile_lambda {cxt with st = NeedValue; should_return = ReturnFalse} arg - in - let cont block0 block1 obj_code = + begin + let need_value_no_return_cxt = {cxt with st = NeedValue; should_return = ReturnFalse} in + let obj_output = compile_lambda need_value_no_return_cxt obj in + let arg_output = compile_lambda need_value_no_return_cxt arg in + let cont obj_block arg_block obj_code = Js_output.output_of_block_and_expression st should_return lam ( match obj_code with - | None -> Ext_list.append block0 block1 - | Some obj_code -> Ext_list.append block0 @@ obj_code :: block1 + | None -> Ext_list.append obj_block arg_block + | Some obj_code -> Ext_list.append obj_block (obj_code :: arg_block) ) in - match obj_block, value_block with - | {block = block0; value = Some obj }, - {block = block1; value = Some value} + match obj_output, arg_output with + | {block = obj_block; value = Some obj }, + {block = arg_block; value = Some value} -> if Ext_string.ends_with method_name Literals.setter_suffix then let property = - Lam_methname.translate ~loc @@ - String.sub method_name 0 - (String.length method_name - Literals.setter_suffix_len) in + Lam_methname.translate ~loc + (String.sub method_name 0 + (String.length method_name - Literals.setter_suffix_len)) in match Js_ast_util.named_expression obj with | None -> - cont block0 block1 None (E.assign (E.dot obj property) value) + cont obj_block arg_block None + (E.seq (E.assign (E.dot obj property) value) E.unit) | Some (obj_code, obj) -> - cont block0 block1 (Some obj_code) - (E.assign (E.dot (E.var obj) property) value) + cont obj_block arg_block (Some obj_code) + (E.seq (E.assign (E.dot (E.var obj) property) value) E.unit) else compile_lambda cxt (Lam.apply fn [arg]