Skip to content

Switch on uncurried #6864

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 8 commits into from
Jul 17, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
- Ignore `@uncurry` attribute in uncurried mode, to avoid generating calls to `Curry` at runtime. https://github.com/rescript-lang/rescript-compiler/pull/6869
- Avoid generating calls to Curry when adjusting arity of uncurried functions. https://github.com/rescript-lang/rescript-compiler/pull/6870
- Remove `@@uncurried.swap`, which was used for internal tests. https://github.com/rescript-lang/rescript-compiler/pull/6875
- Build the compiler libraries/tests in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6864

#### :nail_care: Polish

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

Here's the original error message
This has type: option<'a>
But it's expected to have type: (. unit) => option<int>
But it's expected to have type: unit => option<int>
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
2 │ let makeVariables = makeVar(.~f=f => f)
3 │

This uncurried function has type (. ~f: 'a => 'a, unit) => int
This uncurried function has type (~f: 'a => 'a, unit) => int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a separate PR, we should change "This uncurried function has ..." to "This function has ...".

It is applied with 1 arguments but it requires 2.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
2 │ let makeVariables = makeVar(. 1, 2, 3)
3 │

This uncurried function has type (. 'a, unit) => int
This uncurried function has type ('a, unit) => int
It is applied with 3 arguments but it requires 2.
Original file line number Diff line number Diff line change
@@ -1,28 +0,0 @@

We've found a bug for you!
/.../fixtures/c_for_u_in_c_mode.res:3:5-5:1

1 │ module Foo: {
2 │ let add: (. int, int) => int
3 │ } = {
4 │  let add = (a, b) => a + b
5 │ }
6 │

Signature mismatch:
Modules do not match:
{
let add: (int, int) => int
}
is not included in
{
let add: (. int, int) => int
}
Values do not match:
let add: (int, int) => int (curried)
is not included in
let add: (. int, int) => int (uncurried)
/.../fixtures/c_for_u_in_c_mode.res:2:3-30:
Expected declaration
/.../fixtures/c_for_u_in_c_mode.res:4:7-9:
Actual declaration
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
3 │ let z1 = expectCurried((. x, y) => x+y)
4 │

This function is an uncurried function where a curried function is expected
This function expected 1 argument, but got 2
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@

We've found a bug for you!
/.../fixtures/curry_in_uncurry.res:3:1

1 │ let f = (a, b) => a + b
2 │
3 │ f(. 2, 2)->Js.log
4 │

This function is a curried function where an uncurried function is expected
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
4 │ }
5 │

This uncurried function has type (. int, int) => unit
This uncurried function has type (int, int) => unit
It is applied with 1 arguments but it requires 2.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

We've found a bug for you!
/.../fixtures/missing_label.res:3:9
/.../fixtures/missing_label.res:3:11-12

1 │ let f = (~a) => a ++ ""
2 │
3 │ let _ = f("")
3 │ let _ = f("")
4 │

Label ~a was omitted in the application of this labeled function.
The function applied to this argument has type (~a: string) => string
This argument cannot be applied without label
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

We've found a bug for you!
/.../fixtures/missing_labels.res:3:9
/.../fixtures/missing_labels.res:3:11-12

1 │ let f = (~a, ~b) => a ++ b
2 │
3 │ let _ = f("", "")
3 │ let _ = f("", "")
4 │

Labels ~a, ~b were omitted in the application of this labeled function.
The function applied to this argument has type
(~a: string, ~b: string) => string
This argument cannot be applied without label
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

We've found a bug for you!
/.../fixtures/moreArguments1.res:2:9-15
/.../fixtures/moreArguments1.res:2:9

1 │ let x = (~a, ~b) => a + b
2 │ let y = x(~a=2) + 2
2 │ let y = x(~a=2) + 2
3 │

This call is missing an argument of type (~b: int)
This uncurried function has type (~a: int, ~b: int) => int
It is applied with 1 arguments but it requires 2.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

We've found a bug for you!
/.../fixtures/moreArguments2.res:2:9-12
/.../fixtures/moreArguments2.res:2:9

1 │ let x = (a, b) => a + b
2 │ let y = x(2) + 2
2 │ let y = x(2) + 2
3 │

This call is missing an argument of type int
This uncurried function has type (int, int) => int
It is applied with 1 arguments but it requires 2.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

We've found a bug for you!
/.../fixtures/moreArguments3.res:2:9-12
/.../fixtures/moreArguments3.res:2:9

1 │ let x = (a, b, c, d) => a + b
2 │ let y = x(2) + 2
2 │ let y = x(2) + 2
3 │

This call is missing arguments of type: int, 'a, 'b
This uncurried function has type (int, int, 'a, 'b) => int
It is applied with 1 arguments but it requires 4.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

We've found a bug for you!
/.../fixtures/moreArguments4.res:2:9-12
/.../fixtures/moreArguments4.res:2:9

1 │ let x = (a, ~b, ~c, ~d) => a + b
2 │ let y = x(2) + 2
2 │ let y = x(2) + 2
3 │

This call is missing arguments of type: (~b: int), (~c: 'a), (~d: 'b)
This uncurried function has type (int, ~b: int, ~c: 'a, ~d: 'b) => int
It is applied with 1 arguments but it requires 4.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

We've found a bug for you!
/.../fixtures/moreArguments5.res:5:9-12
/.../fixtures/moreArguments5.res:5:9

3 │ }
4 │ let x = (a, b, c, d) => {Sub.a: 2}
5 │ let y = x(2).Sub.a
5 │ let y = x(2).Sub.a
6 │

This call is missing arguments of type: 'a, 'b, 'c
This uncurried function has type (int, 'a, 'b, 'c) => Sub.a
It is applied with 1 arguments but it requires 4.
15 changes: 5 additions & 10 deletions jscomp/build_tests/super_errors/expected/partial_app.res.expected
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@

Warning number 109 (configured as error)
/.../fixtures/partial_app.res:5:1-7
We've found a bug for you!
/.../fixtures/partial_app.res:5:1

3 │ }
4 │
5 │ f(1, 2)
5 │ f(1, 2)
6 │

This function call is at the top level and is expected to return `unit`. But it's returning `int => int`.

In ReScript, anything at the top level must evaluate to `unit`. You can fix this by assigning the expression to a value, or piping it into the `ignore` function.

Possible solutions:
- Assigning to a value that is then ignored: `let _ = yourFunctionCall()`
- Piping into the built-in ignore function to ignore the result: `yourFunctionCall()->ignore`
This uncurried function has type (int, int, int) => int
It is applied with 2 arguments but it requires 3.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
3 │ x(2, 4)
4 │

This function has type int => int
It only accepts 1 argument; here, it's called with more.
This uncurried function has type int => int
It is applied with 2 arguments but it requires 1.
Original file line number Diff line number Diff line change
@@ -1,28 +0,0 @@

We've found a bug for you!
/.../fixtures/u_for_c_in_c_mode.res:3:5-5:1

1 │ module Foo: {
2 │ let add: (int, int) => int
3 │ } = {
4 │  let add = (. a, b) => a + b
5 │ }
6 │

Signature mismatch:
Modules do not match:
{
let add: (. int, int) => int
}
is not included in
{
let add: (int, int) => int
}
Values do not match:
let add: (. int, int) => int (uncurried)
is not included in
let add: (int, int) => int (curried)
/.../fixtures/u_for_c_in_c_mode.res:2:3-28:
Expected declaration
/.../fixtures/u_for_c_in_c_mode.res:4:7-9:
Actual declaration
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@

We've found a bug for you!
/.../fixtures/uncurried_expected.res:2:15-22

1 │ let apply = (f) => f(. 1)
2 │ let z = apply(x => x+1)
3 │

This expression is expected to have an uncurried function
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
3 │ let d = foo(. ~y=3)
4 │

The function applied to this argument has type (. ~x: int, ~y: int) => int
The function applied to this argument has type
(~x: int) => (~y: int) => int
This argument cannot be applied with label ~y
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

We've found a bug for you!
/.../fixtures/warnings1.res:3:3-7
/.../fixtures/warnings1.res:3:3

1 │ let x = (a, b) => a + b
2 │ let z = () => {
3 │ x(10)
3 │ x(10)
4 │ 10
5 │ }

This function call returns: int => int
But it's expected to return: unit
This uncurried function has type (int, int) => int
It is applied with 1 arguments but it requires 2.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
2 │ let _ = string_of_float(34.)
3 │ let _ = string_of_float(34.)

deprecated: Pervasives.string_of_float
deprecated: PervasivesU.string_of_float
Please use Js.Float.toString instead, string_of_float generates unparseable floats


Expand All @@ -18,7 +18,7 @@
3 │ let _ = string_of_float(34.)
4 │

deprecated: Pervasives.string_of_float
deprecated: PervasivesU.string_of_float
Please use Js.Float.toString instead, string_of_float generates unparseable floats


Expand All @@ -30,5 +30,5 @@
3 │ let _ = string_of_float(34.)
4 │

deprecated: Pervasives.string_of_float
deprecated: PervasivesU.string_of_float
Please use Js.Float.toString instead, string_of_float generates unparseable floats
2 changes: 1 addition & 1 deletion jscomp/build_tests/super_errors/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fixtures = fs
.filter(fileName => path.extname(fileName) === ".res");

// const runtime = path.join(__dirname, '..', '..', 'runtime')
const prefix = `${bsc} -w +A`;
const prefix = `${bsc} -w +A -uncurried`;

const updateTests = process.argv[2] === "update";

Expand Down
Loading