Skip to content

Treat uncurried application of primitives like curried application #5851

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
Nov 26, 2022
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 @@ -54,6 +54,7 @@ These are only breaking changes for unformatted code.
- Remove method application via operator `##`, which does not exist in `.res` syntax https://github.com/rescript-lang/rescript-compiler/pull/5844
- Treat `@meth` annotation as making the type uncurried for backwards compatibitly with some examples https://github.com/rescript-lang/rescript-compiler/pull/5845
- Process `@set` annotation for field update as generating an uncurried function https://github.com/rescript-lang/rescript-compiler/pull/5846
- Treat uncurried application of primitives like curried application, which produces better output https://github.com/rescript-lang/rescript-compiler/pull/5851

# 10.1.0-rc.6

Expand Down
6 changes: 5 additions & 1 deletion jscomp/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,11 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
exp_attributes = sexp.pexp_attributes;
exp_env = env } in

if fully_applied then
let is_primitive = match funct.exp_desc with
| Texp_ident (_, _, {val_kind = Val_prim _}) -> true
| _ -> false in

if fully_applied && not is_primitive then
rue (apply_internal "opaqueFullApply" (mk_apply (apply_internal "opaque" funct) args))
else
rue (mk_apply funct args)
Expand Down
16 changes: 6 additions & 10 deletions jscomp/test/UncurriedExternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ function tg(arr) {

var tc = Object.assign({}, "abc");

var te = (function (prim) {
return prim;
})({
RE_EXN_ID: "Not_found"
});
var te = {
RE_EXN_ID: "Not_found"
};

var tcr = {};

Expand Down Expand Up @@ -87,11 +85,9 @@ function tg$1(arr) {

var tc$1 = Object.assign({}, "abc");

var te$1 = (function (prim) {
return prim;
})({
RE_EXN_ID: "Not_found"
});
var te$1 = {
RE_EXN_ID: "Not_found"
};

var tcr$1 = {};

Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/bs_splice_partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function test_cb(x) {
}

function f(x) {
v(x);
Curry._1(v, x);
}

function testUndefined(param) {
Expand Down
6 changes: 5 additions & 1 deletion lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42771,7 +42771,11 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
exp_attributes = sexp.pexp_attributes;
exp_env = env } in

if fully_applied then
let is_primitive = match funct.exp_desc with
| Texp_ident (_, _, {val_kind = Val_prim _}) -> true
| _ -> false in

if fully_applied && not is_primitive then
rue (apply_internal "opaqueFullApply" (mk_apply (apply_internal "opaque" funct) args))
else
rue (mk_apply funct args)
Expand Down
6 changes: 5 additions & 1 deletion lib/4.06.1/unstable/js_playground_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42771,7 +42771,11 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
exp_attributes = sexp.pexp_attributes;
exp_env = env } in

if fully_applied then
let is_primitive = match funct.exp_desc with
| Texp_ident (_, _, {val_kind = Val_prim _}) -> true
| _ -> false in

if fully_applied && not is_primitive then
rue (apply_internal "opaqueFullApply" (mk_apply (apply_internal "opaque" funct) args))
else
rue (mk_apply funct args)
Expand Down
6 changes: 5 additions & 1 deletion lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97765,7 +97765,11 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
exp_attributes = sexp.pexp_attributes;
exp_env = env } in

if fully_applied then
let is_primitive = match funct.exp_desc with
| Texp_ident (_, _, {val_kind = Val_prim _}) -> true
| _ -> false in

if fully_applied && not is_primitive then
rue (apply_internal "opaqueFullApply" (mk_apply (apply_internal "opaque" funct) args))
else
rue (mk_apply funct args)
Expand Down