Skip to content
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

Treat uncurried application of primitives like curried application #5851

Merged
merged 1 commit into from
Nov 26, 2022
Merged
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
@@ -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

6 changes: 5 additions & 1 deletion jscomp/ml/typecore.ml
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 6 additions & 10 deletions jscomp/test/UncurriedExternals.js
Original file line number Diff line number Diff line change
@@ -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 = {};

@@ -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 = {};

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

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

function testUndefined(param) {
6 changes: 5 additions & 1 deletion lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
@@ -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)
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
@@ -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)
6 changes: 5 additions & 1 deletion lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
@@ -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)