Skip to content

Commit f900308

Browse files
committed
Fix issue with uninitialized _param in recursive functions with unit argument.
Fixes #6719
1 parent e3d8536 commit f900308

File tree

6 files changed

+32
-38
lines changed

6 files changed

+32
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
- Avoid generation of `Curry` with reverse application `|>`. https://github.com/rescript-lang/rescript-compiler/pull/6876
5050
- 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
5151
- 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
52+
- Fix issue with uninitialized `_param` in recursive functions with unit argument. https://github.com/rescript-lang/rescript-compiler/pull/6907
5253

5354
#### :house: Internal
5455

jscomp/core/lam_compile.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ and compile_recursive_let ~all_bindings (cxt : Lam_compile_context.t)
357357
it will be renamed into [method]
358358
when it is detected by a primitive
359359
*)
360-
~return_unit ~async ~one_unit_arg ?directive ~immutable_mask:ret.immutable_mask
360+
~return_unit ~async ~one_unit_arg:false ?directive ~immutable_mask:ret.immutable_mask
361361
(Ext_list.map params (fun x ->
362362
Map_ident.find_default ret.new_params x x))
363363
[
@@ -1465,7 +1465,6 @@ and compile_apply (appinfo : Lam.apply) (lambda_cxt : Lam_compile_context.t) =
14651465
*)
14661466
(* TODO: use [fold]*)
14671467
let _, assigned_params, new_params =
1468-
let args = if ret.params = [] then [] else args in
14691468
Ext_list.fold_left2 ret.params args (0, [], Map_ident.empty)
14701469
(fun param arg (i, assigns, new_params) ->
14711470
match arg with

jscomp/test/ocaml_re_test.js

Lines changed: 9 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/uncurry_test.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/es6/stream.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,17 @@ function empty(s) {
258258
}
259259

260260
function iter(f, strm) {
261-
let do_rec = function () {
262-
while(true) {
263-
let a = peek(strm);
264-
if (a === undefined) {
265-
return;
266-
}
267-
junk(strm);
268-
f(Caml_option.valFromOption(a));
269-
_param = undefined;
270-
continue;
271-
};
261+
let _param;
262+
while(true) {
263+
let a = peek(strm);
264+
if (a === undefined) {
265+
return;
266+
}
267+
junk(strm);
268+
f(Caml_option.valFromOption(a));
269+
_param = undefined;
270+
continue;
272271
};
273-
do_rec();
274272
}
275273

276274
function from(f) {

lib/js/stream.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,17 @@ function empty(s) {
258258
}
259259

260260
function iter(f, strm) {
261-
let do_rec = function () {
262-
while(true) {
263-
let a = peek(strm);
264-
if (a === undefined) {
265-
return;
266-
}
267-
junk(strm);
268-
f(Caml_option.valFromOption(a));
269-
_param = undefined;
270-
continue;
271-
};
261+
let _param;
262+
while(true) {
263+
let a = peek(strm);
264+
if (a === undefined) {
265+
return;
266+
}
267+
junk(strm);
268+
f(Caml_option.valFromOption(a));
269+
_param = undefined;
270+
continue;
272271
};
273-
do_rec();
274272
}
275273

276274
function from(f) {

0 commit comments

Comments
 (0)