Skip to content

Fix issue with uncurried function with 1 arg being a variable #6507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#### :bug: Bug Fix
- Fix issue where an inline record with attributes did not parse. https://github.com/rescript-lang/rescript-compiler/pull/6499
- Fix issue with uncurried function with 1 arg being a variable where an undefined variable could be emitted. https://github.com/rescript-lang/rescript-compiler/pull/6507

# 11.0.0-rc.6

Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam_pass_alpha_conversion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let alpha_conversion (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
| None -> Lam.prim ~primitive ~args:[ simpl arg ] loc)
| Lprim { primitive = Pjs_fn_make_unit; args = [ arg ]; loc } ->
let arg = match arg with
| Lfunction ({arity=1; params=[x]; attr; body}) ->
| Lfunction ({arity=1; params=[x]; attr; body}) when Ident.name x = "param" (* "()" *) ->
Lam.function_ ~params:[x] ~attr:{attr with oneUnitArg=true} ~body ~arity:1
| _ -> arg in
simpl arg
Expand Down
25 changes: 24 additions & 1 deletion jscomp/test/UncurriedAlways.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions jscomp/test/UncurriedAlways.res
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ module OptMixed = {
let c3 = ptl(~x="x", ~z="z", ~d2="d2<-200", ~d4="d4<-400")
Js.log2("c3:", c3)
}

let fn = cb => {
cb()
}

fn(s => Js.log(#foo(s)))

let fn1 = (a, b, ()) => a() + b

let a = fn1(() => 1, 2, _)