From f1ddd583b8e1ff303bd5f8b456198a8e0a4393ab Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 24 Jul 2024 17:11:01 +0200 Subject: [PATCH] Fix issue with uninitialized `_param` in recursive functions with unit argument. Fixes https://github.com/rescript-lang/rescript-compiler/issues/6719 --- CHANGELOG.md | 1 + jscomp/core/lam_compile.ml | 1 + jscomp/test/ocaml_re_test.js | 1 - jscomp/test/uncurry_test.js | 1 - lib/es6/stream.js | 1 - lib/js/stream.js | 1 - 6 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba2a0b5c2b..2bfd8916f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ - Avoid generation of `Curry` with reverse application `|>`. https://github.com/rescript-lang/rescript-compiler/pull/6876 - Fix issue where the internal ppx for pipe `->` would not use uncurried application in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6878 - Fix build after calling without `-warn-error`, see https://github.com/rescript-lang/rescript-compiler/issues/6868 for more details. https://github.com/rescript-lang/rescript-compiler/pull/6877 +- Fix issue with uninitialized `_param` in recursive functions with unit argument. https://github.com/rescript-lang/rescript-compiler/pull/6907 #### :house: Internal diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 4065d9c27f..b782e12966 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -327,6 +327,7 @@ and compile_recursive_let ~all_bindings (cxt : Lam_compile_context.t) ]} [Alias] may not be exact *) + let params = if one_unit_arg then [] else params in let ret : Lam_compile_context.return_label = { id; diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index dfcd0828f2..4ec6be2f10 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -4187,7 +4187,6 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { return epsilon; } i.contents = i.contents + 1 | 0; - _param = undefined; continue; }; }; diff --git a/jscomp/test/uncurry_test.js b/jscomp/test/uncurry_test.js index 80632c7bcc..d88d252252 100644 --- a/jscomp/test/uncurry_test.js +++ b/jscomp/test/uncurry_test.js @@ -28,7 +28,6 @@ console.log([ function xx() { while(true) { - _param = undefined; continue; }; } diff --git a/lib/es6/stream.js b/lib/es6/stream.js index 5d6058b378..a6bf804d7b 100644 --- a/lib/es6/stream.js +++ b/lib/es6/stream.js @@ -266,7 +266,6 @@ function iter(f, strm) { } junk(strm); f(Caml_option.valFromOption(a)); - _param = undefined; continue; }; }; diff --git a/lib/js/stream.js b/lib/js/stream.js index 2ee0c6b4be..c8db66eb78 100644 --- a/lib/js/stream.js +++ b/lib/js/stream.js @@ -266,7 +266,6 @@ function iter(f, strm) { } junk(strm); f(Caml_option.valFromOption(a)); - _param = undefined; continue; }; };