Skip to content

Commit cc00e83

Browse files
authored
Disable warning on inline attibute on uncurried function. (#6152)
Fixes #6149
1 parent 85a34fa commit cc00e83

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Fix broken formatting in uncurried mode for functions with _ placeholder args. https://github.com/rescript-lang/rescript-compiler/pull/6148
1818
- Fix issue where spreading record types with optional labels would not have their labels preserved as optional. https://github.com/rescript-lang/rescript-compiler/pull/6154
1919
- Fix error location to be the type with the spreads when spreading record types with duplicate labels. https://github.com/rescript-lang/rescript-compiler/pull/6157
20+
- Disable warning on `@inline` attibute on uncurried functions. https://github.com/rescript-lang/rescript-compiler/pull/6152
2021

2122
# 11.0.0-alpha.3
2223

jscomp/ml/translattribute.ml

+8-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ let get_inline_attribute l =
6262
let attr, _ = find_attribute is_inline_attribute l in
6363
parse_inline_attribute attr
6464

65-
let add_inline_attribute (expr : Lambda.lambda) loc attributes =
65+
let rec add_inline_attribute (expr : Lambda.lambda) loc attributes =
6666
match (expr, get_inline_attribute attributes) with
6767
| expr, Default_inline -> expr
6868
| Lfunction ({ attr = { stub = false } as attr } as funct), inline ->
@@ -72,8 +72,13 @@ let add_inline_attribute (expr : Lambda.lambda) loc attributes =
7272
Location.prerr_warning loc (Warnings.Duplicated_attribute "inline"));
7373
let attr = { attr with inline } in
7474
Lfunction { funct with attr }
75-
| expr, (Always_inline | Never_inline) ->
76-
Location.prerr_warning loc (Warnings.Misplaced_attribute "inline");
75+
| Lprim (Pccall {prim_name = "#fn_mk" | "#fn_mk_unit"} as p, [e], l), _ ->
76+
Lambda.Lprim (p, [add_inline_attribute e loc attributes], l)
77+
| expr, (Always_inline) ->
78+
Location.prerr_warning loc (Warnings.Misplaced_attribute "inline1");
79+
expr
80+
| expr, (Never_inline) ->
81+
Location.prerr_warning loc (Warnings.Misplaced_attribute "inline2");
7782
expr
7883

7984
(* Get the [@inlined] attribute payload (or default if not present).

jscomp/test/UncurriedAlways.js

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ function q(param) {
4747
return null;
4848
}
4949

50+
function inl() {
51+
52+
}
53+
54+
function inl2(x, y) {
55+
return x + y | 0;
56+
}
57+
5058
exports.foo = foo;
5159
exports.z = z;
5260
exports.bar = bar;
@@ -59,4 +67,6 @@ exports.bar2 = bar2;
5967
exports.foo3 = foo3;
6068
exports.bar3 = bar3;
6169
exports.q = q;
70+
exports.inl = inl;
71+
exports.inl2 = inl2;
6272
/* Not a pure module */

jscomp/test/UncurriedAlways.res

+6
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ let bar3: _ => _ = foo3(_, 3, 4)
2626

2727
type cmp = Jsx.component<int>
2828
let q: cmp = _ => Jsx.null // Check that subtyping works past type definitions
29+
30+
@inline
31+
let inl = () => ()
32+
33+
@inline
34+
let inl2 = (x,y) => x+y

0 commit comments

Comments
 (0)