From a7a95e24e824278b8949af39670019f0b6ea1404 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Wed, 5 Jul 2017 03:37:38 +0800 Subject: [PATCH 1/3] fix #1762 --- jscomp/bin/bsb_watcher.js | 2 +- jscomp/bin/whole_compiler.ml | 3 ++- jscomp/core/lam_compile.ml | 3 ++- jscomp/test/.depend | 3 +++ jscomp/test/Makefile | 6 +++++- jscomp/test/gpr_1759_test.js | 5 +++++ jscomp/test/gpr_1759_test.ml | 8 ++++++++ jscomp/test/gpr_1760_test.js | 5 +++++ jscomp/test/gpr_1760_test.ml | 4 ++++ jscomp/test/gpr_1762_test.js | 7 +++++++ jscomp/test/gpr_1762_test.ml | 4 ++++ 11 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 jscomp/test/gpr_1759_test.js create mode 100644 jscomp/test/gpr_1759_test.ml create mode 100644 jscomp/test/gpr_1760_test.js create mode 100644 jscomp/test/gpr_1760_test.ml create mode 100644 jscomp/test/gpr_1762_test.js create mode 100644 jscomp/test/gpr_1762_test.ml diff --git a/jscomp/bin/bsb_watcher.js b/jscomp/bin/bsb_watcher.js index 060285a458..843d8a98d2 100644 --- a/jscomp/bin/bsb_watcher.js +++ b/jscomp/bin/bsb_watcher.js @@ -1,4 +1,4 @@ -//@ts-check + var fs = require('fs') var child_process = require('child_process') diff --git a/jscomp/bin/whole_compiler.ml b/jscomp/bin/whole_compiler.ml index f26341a0eb..7c2c75c488 100644 --- a/jscomp/bin/whole_compiler.ml +++ b/jscomp/bin/whole_compiler.ml @@ -96815,7 +96815,8 @@ and begin match Js_exp_make.extract_non_pure out1 , Js_exp_make.extract_non_pure out2 with - | None, None -> Js_output.make b + | None, None -> Js_output.make (b @ [ S.exp e]) + (* FIX #1762 *) | Some out1, Some out2 -> Js_output.make b ~value:(E.econd e out1 out2) | Some out1, None -> diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 1b0917877b..331504d3ff 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -1019,7 +1019,8 @@ and begin match Js_exp_make.extract_non_pure out1 , Js_exp_make.extract_non_pure out2 with - | None, None -> Js_output.make b + | None, None -> Js_output.make (b @ [ S.exp e]) + (* FIX #1762 *) | Some out1, Some out2 -> Js_output.make b ~value:(E.econd e out1 out2) | Some out1, None -> diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 6e8c53c51c..6cd0207ca7 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -235,6 +235,9 @@ gpr_1716_test.cmj : mt.cmj gpr_1717_test.cmj : gpr_1728_test.cmj : mt.cmj gpr_1749_test.cmj : mt.cmj +gpr_1759_test.cmj : +gpr_1760_test.cmj : +gpr_1762_test.cmj : gpr_405_test.cmj : ../stdlib/hashtbl.cmj gpr_405_test.cmi gpr_441.cmj : gpr_459_test.cmj : mt.cmj diff --git a/jscomp/test/Makefile b/jscomp/test/Makefile index 4f14e74e33..b09066cff9 100644 --- a/jscomp/test/Makefile +++ b/jscomp/test/Makefile @@ -169,7 +169,11 @@ OTHERS := literals a test_ari test_export2 test_internalOO test_obj_simple_ffi t gpr_1409_test\ rec_fun_test\ gpr_1749_test\ - ocaml_re_test + ocaml_re_test\ + gpr_1762_test\ + gpr_1760_test\ + gpr_1759_test + # bs_uncurry_test # needs Lam to get rid of Uncurry arity first diff --git a/jscomp/test/gpr_1759_test.js b/jscomp/test/gpr_1759_test.js new file mode 100644 index 0000000000..6d8a4a3f94 --- /dev/null +++ b/jscomp/test/gpr_1759_test.js @@ -0,0 +1,5 @@ +'use strict'; + + + +/* No side effect */ diff --git a/jscomp/test/gpr_1759_test.ml b/jscomp/test/gpr_1759_test.ml new file mode 100644 index 0000000000..6db9b3e2ed --- /dev/null +++ b/jscomp/test/gpr_1759_test.ml @@ -0,0 +1,8 @@ + + +(*;; let i:int = + (compare (print_string "") ()) + in print_int i + +;; print_string +(if (<>) () (print_string "") then "true" else "false") *) \ No newline at end of file diff --git a/jscomp/test/gpr_1760_test.js b/jscomp/test/gpr_1760_test.js new file mode 100644 index 0000000000..6d8a4a3f94 --- /dev/null +++ b/jscomp/test/gpr_1760_test.js @@ -0,0 +1,5 @@ +'use strict'; + + + +/* No side effect */ diff --git a/jscomp/test/gpr_1760_test.ml b/jscomp/test/gpr_1760_test.ml new file mode 100644 index 0000000000..22f448f4e7 --- /dev/null +++ b/jscomp/test/gpr_1760_test.ml @@ -0,0 +1,4 @@ + +(*;; print_int (let _c = (/) 0 0 in 0) + +;; print_int (let _h = ((mod) 0 0) in 0)*) \ No newline at end of file diff --git a/jscomp/test/gpr_1762_test.js b/jscomp/test/gpr_1762_test.js new file mode 100644 index 0000000000..a999d1d985 --- /dev/null +++ b/jscomp/test/gpr_1762_test.js @@ -0,0 +1,7 @@ +'use strict'; + +var Pervasives = require("../../lib/js/pervasives.js"); + +Pervasives.bool_of_string("x"); + +/* Not a pure module */ diff --git a/jscomp/test/gpr_1762_test.ml b/jscomp/test/gpr_1762_test.ml new file mode 100644 index 0000000000..7f1e258f48 --- /dev/null +++ b/jscomp/test/gpr_1762_test.ml @@ -0,0 +1,4 @@ + + + +if bool_of_string "x" then "" else "" From bd2adf83bb8e7542c7e48e3550d7560d65852411 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Wed, 5 Jul 2017 03:50:05 +0800 Subject: [PATCH 2/3] update test cases --- jscomp/test/.depend | 2 +- jscomp/test/gpr_1762_test.js | 42 ++++++++++++++++++++++++++++++++++-- jscomp/test/gpr_1762_test.ml | 23 +++++++++++++++++++- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 6cd0207ca7..2292d879cc 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -237,7 +237,7 @@ gpr_1728_test.cmj : mt.cmj gpr_1749_test.cmj : mt.cmj gpr_1759_test.cmj : gpr_1760_test.cmj : -gpr_1762_test.cmj : +gpr_1762_test.cmj : mt.cmj gpr_405_test.cmj : ../stdlib/hashtbl.cmj gpr_405_test.cmi gpr_441.cmj : gpr_459_test.cmj : mt.cmj diff --git a/jscomp/test/gpr_1762_test.js b/jscomp/test/gpr_1762_test.js index a999d1d985..b46978e167 100644 --- a/jscomp/test/gpr_1762_test.js +++ b/jscomp/test/gpr_1762_test.js @@ -1,7 +1,45 @@ 'use strict'; -var Pervasives = require("../../lib/js/pervasives.js"); +var Mt = require("./mt.js"); +var Block = require("../../lib/js/block.js"); -Pervasives.bool_of_string("x"); +var suites = [/* [] */0]; +var test_id = [0]; + +function eq(loc, x, y) { + test_id[0] = test_id[0] + 1 | 0; + suites[0] = /* :: */[ + /* tuple */[ + loc + (" id " + test_id[0]), + (function () { + return /* Eq */Block.__(0, [ + x, + y + ]); + }) + ], + suites[0] + ]; + return /* () */0; +} + +var v = [3]; + +function update() { + v[0] = v[0] + 1 | 0; + return /* true */1; +} + +v[0] = v[0] + 1 | 0; + +eq("File \"gpr_1762_test.ml\", line 22, characters 6-13", v[0], 4); + +Mt.from_pair_suites("gpr_1762_test.ml", suites[0]); + +exports.suites = suites; +exports.test_id = test_id; +exports.eq = eq; +exports.v = v; +exports.update = update; /* Not a pure module */ diff --git a/jscomp/test/gpr_1762_test.ml b/jscomp/test/gpr_1762_test.ml index 7f1e258f48..1cf5aee3aa 100644 --- a/jscomp/test/gpr_1762_test.ml +++ b/jscomp/test/gpr_1762_test.ml @@ -1,4 +1,25 @@ -if bool_of_string "x" then "" else "" +(*;; if bool_of_string "x" then "" else "" *) + + + +let suites : Mt.pair_suites ref = ref [] +let test_id = ref 0 +let eq loc x y = + incr test_id ; + suites := + (loc ^" id " ^ (string_of_int !test_id), (fun _ -> Mt.Eq(x,y))) :: !suites + + +let v = ref 3 + +let update () = incr v ; true + +;; if update () then "" else "" + +;; eq __LOC__ !v 4 + + +;; Mt.from_pair_suites __FILE__ !suites \ No newline at end of file From 6ee80710cf8d57be4158eabe97b0899893e6cba3 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Wed, 5 Jul 2017 03:51:02 +0800 Subject: [PATCH 3/3] [ci skip] update changelog --- Changes.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index 536f73152e..bc6ef89337 100644 --- a/Changes.md +++ b/Changes.md @@ -1,7 +1,9 @@ - -# Next +# 1.8.1 Fixes: +- #1762 +# 1.8.0 +Fixes: - #1573, don't include `-bs` flags in `.merlin` - #1716, fix wrong optimization of recursive values - #1728, bad inlining