Skip to content

Commit a164042

Browse files
committed
Ignore @uncurry attribute in uncurried mode.
Turns out that `@uncurry` attribute even in uncurried mode can produce js code that used`Curry`. The `@uncurry` attribute will be deprecated. For now, this PR ignores it.
1 parent 2201333 commit a164042

7 files changed

+52
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
- Make compiler libs ready for uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6861
5858
- Make tests ready for uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6862
5959
- Make gentype tests uncurried. https://github.com/rescript-lang/rescript-compiler/pull/6866
60+
- Ignore `@uncurry` attribute in uncurried mode, to avoid generating calls to `Curry` at runtime. https://github.com/rescript-lang/rescript-compiler/pull/6869
61+
6062
#### :nail_care: Polish
6163

6264
- Make the `--help` arg be prioritized in the CLI, so correctly prints help message and skip other commands. https://github.com/rescript-lang/rescript-compiler/pull/6667

jscomp/frontend/ast_attributes.ml

+4-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ let iter_process_bs_string_int_unwrap_uncurry (attrs : t) =
194194
| "int" -> assign `Int attr
195195
| "ignore" -> assign `Ignore attr
196196
| "unwrap" -> assign `Unwrap attr
197-
| "uncurry" -> assign (`Uncurry (Ast_payload.is_single_int payload)) attr
197+
| "uncurry" ->
198+
if !Config.uncurried = Uncurried then
199+
Used_attributes.mark_used_attribute attr
200+
else assign (`Uncurry (Ast_payload.is_single_int payload)) attr
198201
| _ -> ());
199202
!st
200203

jscomp/test/build.ninja

+3-1
Large diffs are not rendered by default.

jscomp/test/ignore_uncurry_attribute.js

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@@uncurried
2+
3+
external map1: (array<'a>, @uncurry ('a => 'b)) => array<'b> = "map"
4+
let map1 = map1
5+
6+
external map2: (array<'a>, ('a => 'b)) => array<'b> = "map"
7+
let map2 = map2

jscomp/test/keep_uncurry_attribute.js

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
external map1: (array<'a>, @uncurry ('a => 'b)) => array<'b> = "map"
2+
let map1 = map1
3+
4+
external map2: (array<'a>, ('a => 'b)) => array<'b> = "map"
5+
let map2 = map2

0 commit comments

Comments
 (0)