Skip to content

Commit 6c2bebe

Browse files
authored
Remove deprecated uncurried function syntax (#8211)
* Remove deprecated uncurried function syntax * CHANGELOG
1 parent d4a533b commit 6c2bebe

File tree

119 files changed

+911
-929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+911
-929
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- `Int.fromString` and `Float.fromString` use stricter number parsing and no longer uses an explicit radix argument, but instead supports parsing hexadecimal, binary and exponential notation.
2020
- Remove the deprecated module system names `es6` and `es6-global` (superseded by `esmodule`). https://github.com/rescript-lang/rescript/pull/8205
2121
- Remove `external-stdlib` configuration option from `rescript.json`. This option was rarely used and is no longer supported.
22+
- Remove the deprecated uncurried `(. args) => ...` function syntax. https://github.com/rescript-lang/rescript/pull/8211
2223
- `js-post-build` now passes the correct output file path based on `in-source` configuration: when `in-source: true`, the path next to the source file is passed; when `in-source: false`, the path in the `lib/<module>/` directory is passed. Additionally, stdout and stderr from the post-build command are now logged. https://github.com/rescript-lang/rescript/pull/8190
2324
- `js-post-build` command now runs in the directory containing the `rescript.json` where it is defined, instead of the unpredictable build invocation directory. This provides consistent behavior in monorepos. https://github.com/rescript-lang/rescript/pull/8195
2425
- Remove support for deprecated `bs-dependencies`, `bs-dev-dependencies`, and `bsc-flags` configuration options. Use `dependencies`, `dev-dependencies`, and `compiler-flags` instead. https://github.com/rescript-lang/rescript/pull/8196

analysis/examples/example-project/src/ZZ.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ let v1 = V1
8585

8686
module DoubleNested = ModuleWithDocComment.Nested.NestedAgain
8787

88-
let uncurried = (. x) => x + 1
88+
let uncurried = (x) => x + 1
8989

9090
module Inner = {
9191
type tInner = int

analysis/examples/larger-project/src/BucklescriptAnnotations.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ type someMutableFields = {
1212
@genType
1313
type someMethods = {
1414
"send": string => unit,
15-
"on": (string, (. int) => unit) => unit,
15+
"on": (string, (int) => unit) => unit,
1616
"threeargs": (int, string, int) => string,
17-
"twoArgs": (. int, string) => int,
17+
"twoArgs": (int, string) => int,
1818
}
1919

2020
// let foo = (x: someMethods) => x["threeargs"](3, "a", 4)
2121

2222
let bar = (x: someMethods) => {
2323
let f = x["twoArgs"]
24-
f(. 3, "a")
24+
f(3, "a")
2525
}

analysis/examples/larger-project/src/Docstrings.res

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let flat = 34
99
* @returns A signed message
1010
")
1111
@genType
12-
let signMessage = (. message, key) => message ++ string_of_int(key)
12+
let signMessage = (message, key) => message ++ string_of_int(key)
1313

1414
@genType
1515
let one = a => a + 0
@@ -21,31 +21,31 @@ let two = (a, b) => a + b + 0
2121
let tree = (a, b, c) => a + b + c + 0
2222

2323
@genType
24-
let oneU = (. a) => a + 0
24+
let oneU = (a) => a + 0
2525

2626
@genType
27-
let twoU = (. a, b) => a + b + 0
27+
let twoU = (a, b) => a + b + 0
2828

2929
@genType
30-
let treeU = (. a, b, c) => a + b + c + 0
30+
let treeU = (a, b, c) => a + b + c + 0
3131

3232
@genType
3333
let useParam = param => param + 34
3434

3535
@genType
36-
let useParamU = (. param) => param + 34
36+
let useParamU = (param) => param + 34
3737

3838
@genType
3939
let unnamed1 = (_: int) => 34
4040

4141
@genType
42-
let unnamed1U = (. _: int) => 34
42+
let unnamed1U = (_: int) => 34
4343

4444
@genType
4545
let unnamed2 = (_: int, _: int) => 34
4646

4747
@genType
48-
let unnamed2U = (. _: int, _: int) => 34
48+
let unnamed2U = (_: int, _: int) => 34
4949

5050
@genType
5151
let grouped = (~x, ~y, a, b, c, ~z) => x + y + a + b + c + z
@@ -54,7 +54,7 @@ let grouped = (~x, ~y, a, b, c, ~z) => x + y + a + b + c + z
5454
let unitArgWithoutConversion = () => "abc"
5555

5656
@genType
57-
let unitArgWithoutConversionU = (. ()) => "abc"
57+
let unitArgWithoutConversionU = (()) => "abc"
5858

5959
type t =
6060
| A
@@ -64,4 +64,4 @@ type t =
6464
let unitArgWithConversion = () => A
6565

6666
@genType
67-
let unitArgWithConversionU = (. ()) => A
67+
let unitArgWithConversionU = (()) => A

analysis/examples/larger-project/src/ImportJsValue.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ let areaValue = area({x: 3, y: None})
3131

3232
module AbsoluteValue = {
3333
@genType.import(("./MyMath", "AbsoluteValue"))
34-
type t = {"getAbs": (. unit) => int}
34+
type t = {"getAbs": (unit) => int}
3535

3636
/* This is untyped */
3737
@send external getProp: t => int = "getProp"
3838

3939
/* This is also untyped, as we "trust" the type declaration in absoluteVaue */
4040
let getAbs = (x: t) => {
4141
let getAbs = x["getAbs"]
42-
getAbs(.)
42+
getAbs()
4343
}
4444
}
4545

analysis/examples/larger-project/src/Uncurried.res

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
@genType
2-
type u0 = (. unit) => string
2+
type u0 = (unit) => string
33

44
@genType
5-
type u1 = (. int) => string
5+
type u1 = (int) => string
66

77
@genType
8-
type u2 = (. int, string) => string
8+
type u2 = (int, string) => string
99

1010
@genType
11-
type u3 = (. int, string, int) => string
11+
type u3 = (int, string, int) => string
1212

1313
@genType
14-
let uncurried0 = (. ()) => ""
14+
let uncurried0 = (()) => ""
1515

1616
@genType
17-
let uncurried1 = (. x) => x |> string_of_int
17+
let uncurried1 = (x) => x |> string_of_int
1818

1919
@genType
20-
let uncurried2 = (. x, y) => (x |> string_of_int) ++ y
20+
let uncurried2 = (x, y) => (x |> string_of_int) ++ y
2121

2222
@genType
23-
let uncurried3 = (. x, y, z) => (x |> string_of_int) ++ (y ++ (z |> string_of_int))
23+
let uncurried3 = (x, y, z) => (x |> string_of_int) ++ (y ++ (z |> string_of_int))
2424

2525
@genType
2626
let curried3 = (x, y, z) => (x |> string_of_int) ++ (y ++ (z |> string_of_int))
@@ -29,19 +29,19 @@ let curried3 = (x, y, z) => (x |> string_of_int) ++ (y ++ (z |> string_of_int))
2929
let callback = cb => cb() |> string_of_int
3030

3131
type auth = {login: unit => string}
32-
type authU = {loginU: (. unit) => string}
32+
type authU = {loginU: (unit) => string}
3333

3434
@genType
3535
let callback2 = auth => auth.login()
3636

3737
@genType
38-
let callback2U = auth => auth.loginU(.)
38+
let callback2U = auth => auth.loginU()
3939

4040
@genType
41-
let sumU = (. n, m) => Js.log4("sumU 2nd arg", m, "result", n + m)
41+
let sumU = (n, m) => Js.log4("sumU 2nd arg", m, "result", n + m)
4242

4343
@genType
44-
let sumU2 = (. n, . m) => Js.log4("sumU2 2nd arg", m, "result", n + m)
44+
let sumU2 = (n, m) => Js.log4("sumU2 2nd arg", m, "result", n + m)
4545

4646
@genType
4747
let sumCurried = n => {

analysis/examples/larger-project/src/res_core.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3882,7 +3882,7 @@ and parseArgument = p =>
38823882
let uncurried = true
38833883
Parser.next(p)
38843884
switch p.token {
3885-
/* apply(.) */
3885+
/* apply() */
38863886
| Rparen =>
38873887
let unitExpr = Ast_helper.Exp.construct(Location.mknoloc(Longident.Lident("()")), None)
38883888

@@ -3992,12 +3992,12 @@ and parseCallExpr = (p, funExpr) => {
39923992
if !loc.loc_ghost &&
39933993
p.mode == ParseForTypeChecker => /* Since there is no syntax space for arity zero vs arity one,
39943994
* we expand
3995-
* `fn(. ())` into
3996-
* `fn(. {let __res_unit = (); __res_unit})`
3995+
* `fn(())` into
3996+
* `fn({let __res_unit = (); __res_unit})`
39973997
* when the parsetree is intended for type checking
39983998
*
39993999
* Note:
4000-
* `fn(.)` is treated as zero arity application.
4000+
* `fn()` is treated as zero arity application.
40014001
* The invisible unit expression here has loc_ghost === true
40024002
*
40034003
* Related: https://github.com/rescript-lang/syntax/issues/138

analysis/examples/larger-project/src/res_printer.res

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ and printTypeDeclarations = (~recFlag, typeDeclarations, cmtTbl) =>
11901190
* type_declaration = {
11911191
* ptype_name: string loc;
11921192
* ptype_params: (core_type * variance) list;
1193-
* (* ('a1,...'an) t; None represents _*)
1193+
* (* ('a1, ...'an) t; None represents _*)
11941194
* ptype_cstrs: (core_type * core_type * Location.t) list;
11951195
* (* ... constraint T1=T1' ... constraint Tn=Tn' *)
11961196
* ptype_kind: type_kind;
@@ -4203,7 +4203,7 @@ and printArgumentsWithCallbackInFirstPosition = (~uncurried, args, cmtTbl) => {
42034203
*/
42044204
let fitsOnOneLine = Doc.concat(list{
42054205
if uncurried {
4206-
Doc.text("(. ")
4206+
Doc.text("(")
42074207
} else {
42084208
Doc.lparen
42094209
},
@@ -4285,7 +4285,7 @@ and printArgumentsWithCallbackInLastPosition = (~uncurried, args, cmtTbl) => {
42854285
/* Thing.map(foo, (arg1, arg2) => MyModuleBlah.toList(argument)) */
42864286
let fitsOnOneLine = Doc.concat(list{
42874287
if uncurried {
4288-
Doc.text("(.")
4288+
Doc.text("(")
42894289
} else {
42904290
Doc.lparen
42914291
},
@@ -4300,7 +4300,7 @@ and printArgumentsWithCallbackInLastPosition = (~uncurried, args, cmtTbl) => {
43004300
*/
43014301
let arugmentsFitOnOneLine = Doc.concat(list{
43024302
if uncurried {
4303-
Doc.text("(.")
4303+
Doc.text("(")
43044304
} else {
43054305
Doc.lparen
43064306
},
@@ -4347,8 +4347,8 @@ and printArguments = (~uncurried, args: list<(Asttypes.arg_label, Parsetree.expr
43474347
* arity zero vs arity one syntax.
43484348
* Related: https://github.com/rescript-lang/syntax/issues/138 */
43494349
switch (uncurried, loc.loc_ghost) {
4350-
| (true, true) => Doc.text("(.)") /* arity zero */
4351-
| (true, false) => Doc.text("(. ())") /* arity one */
4350+
| (true, true) => Doc.text("()") /* arity zero */
4351+
| (true, false) => Doc.text("(())") /* arity one */
43524352
| _ => Doc.text("()")
43534353
}
43544354
| list{(Nolabel, arg)} if ParsetreeViewer.isHuggableExpression(arg) =>
@@ -4363,7 +4363,7 @@ and printArguments = (~uncurried, args: list<(Asttypes.arg_label, Parsetree.expr
43634363

43644364
Doc.concat(list{
43654365
if uncurried {
4366-
Doc.text("(. ")
4366+
Doc.text("(")
43674367
} else {
43684368
Doc.lparen
43694369
},
@@ -4374,7 +4374,7 @@ and printArguments = (~uncurried, args: list<(Asttypes.arg_label, Parsetree.expr
43744374
Doc.group(
43754375
Doc.concat(list{
43764376
if uncurried {
4377-
Doc.text("(.")
4377+
Doc.text("(")
43784378
} else {
43794379
Doc.lparen
43804380
},
@@ -4635,7 +4635,7 @@ and printExprFunParameters = (~inCallback, ~uncurried, ~hasConstraint, parameter
46354635
}
46364636

46374637
let lparen = if uncurried {
4638-
Doc.text("(. ")
4638+
Doc.text("(")
46394639
} else {
46404640
Doc.lparen
46414641
}

analysis/examples/workspace-project/myplugin/src/Promise.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exception JsExn(Js.Exn.t)
44
external unsafeToJsExn: exn => Js.Exn.t = "%identity"
55

66
@new
7-
external make: ((@uncurry (. 'a) => unit, (. 'e) => unit) => unit) => t<'a> = "Promise"
7+
external make: ((@uncurry ('a) => unit, ('e) => unit) => unit) => t<'a> = "Promise"
88

99
@val @scope("Promise")
1010
external resolve: 'a => t<'a> = "resolve"

compiler/syntax/src/res_core.ml

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,11 +1726,9 @@ and parse_es6_arrow_expression ?(arrow_attrs = []) ?(arrow_start_pos = None)
17261726
let start_pos = p.Parser.start_pos in
17271727
Parser.leave_breadcrumb p Grammar.Es6ArrowExpr;
17281728
(* Parsing function parameters and attributes:
1729-
1. Basically, attributes outside of `(...)` are added to the function, except
1730-
the uncurried attribute `(.)` is added to the function. e.g. async, uncurried
1731-
1729+
1. Attributes outside of `(...)` are added to the function, e.g. async.
17321730
2. Attributes inside `(...)` are added to the arguments regardless of whether
1733-
labeled, optional or nolabeled *)
1731+
labeled, optional or nolabeled. *)
17341732
let parameters =
17351733
match term_parameters with
17361734
| Some params -> (None, params)
@@ -1807,9 +1805,6 @@ and parse_es6_arrow_expression ?(arrow_attrs = []) ?(arrow_start_pos = None)
18071805
{arrow_expr with pexp_loc = {arrow_expr.pexp_loc with loc_start = start_pos}}
18081806

18091807
(*
1810-
* dotted_parameter ::=
1811-
* | . parameter
1812-
*
18131808
* parameter ::=
18141809
* | pattern
18151810
* | pattern : type
@@ -1827,14 +1822,10 @@ and parse_es6_arrow_expression ?(arrow_attrs = []) ?(arrow_start_pos = None)
18271822
*)
18281823
and parse_parameter p =
18291824
if
1830-
p.Parser.token = Token.Typ || p.token = Tilde || p.token = Dot
1825+
p.Parser.token = Token.Typ || p.token = Tilde
18311826
|| Grammar.is_pattern_start p.token
18321827
then
18331828
let start_pos = p.Parser.start_pos in
1834-
let _ =
1835-
Parser.optional p Token.Dot
1836-
(* dot is ignored *)
1837-
in
18381829
let attrs = parse_attributes p in
18391830
if p.Parser.token = Typ then (
18401831
Parser.next p;
@@ -1934,7 +1925,6 @@ and parse_parameter_list p =
19341925
* | _
19351926
* | lident
19361927
* | ()
1937-
* | (.)
19381928
* | ( parameter {, parameter} [,] )
19391929
*)
19401930
and parse_parameters p : fundef_type_param option * fundef_term_param list =
@@ -1983,7 +1973,6 @@ and parse_parameters p : fundef_type_param option * fundef_term_param list =
19831973
] )
19841974
| Lparen ->
19851975
Parser.next p;
1986-
ignore (Parser.optional p Dot);
19871976
let type_params, term_params = parse_parameter_list p in
19881977
let term_params =
19891978
if term_params <> [] then term_params else [unit_term_parameter ()]
@@ -3902,29 +3891,13 @@ and parse_switch_expression p =
39023891
* | ~ label-name = ? _ (* syntax sugar *)
39033892
* | ~ label-name = ? expr : type
39043893
*
3905-
* dotted_argument ::=
3906-
* | . argument
39073894
*)
39083895
and parse_argument p : argument option =
39093896
if
39103897
p.Parser.token = Token.Tilde
3911-
|| p.token = Dot || p.token = Underscore
3898+
|| p.token = Underscore
39123899
|| Grammar.is_expr_start p.token
3913-
then
3914-
match p.Parser.token with
3915-
| Dot -> (
3916-
Parser.next p;
3917-
match p.token with
3918-
(* apply(.) *)
3919-
| Rparen ->
3920-
let unit_expr =
3921-
Ast_helper.Exp.construct
3922-
(Location.mknoloc (Longident.Lident "()"))
3923-
None
3924-
in
3925-
Some {label = Asttypes.Nolabel; expr = unit_expr}
3926-
| _ -> parse_argument2 p)
3927-
| _ -> parse_argument2 p
3900+
then parse_argument2 p
39283901
else None
39293902

39303903
and parse_argument2 p : argument option =
@@ -4614,9 +4587,6 @@ and parse_type_alias p typ =
46144587
* note:
46154588
* | attrs ~ident: type_expr -> attrs are on the arrow
46164589
* | attrs type_expr -> attrs are here part of the type_expr
4617-
*
4618-
* dotted_type_parameter ::=
4619-
* | . type_parameter
46204590
*)
46214591
and parse_type_parameter p =
46224592
let doc_attr : Parsetree.attributes =
@@ -4626,16 +4596,8 @@ and parse_type_parameter p =
46264596
[doc_comment_to_attribute loc s]
46274597
| _ -> []
46284598
in
4629-
if
4630-
p.Parser.token = Token.Tilde
4631-
|| p.token = Dot
4632-
|| Grammar.is_typ_expr_start p.token
4633-
then
4599+
if p.Parser.token = Token.Tilde || Grammar.is_typ_expr_start p.token then
46344600
let start_pos = p.Parser.start_pos in
4635-
let _ =
4636-
Parser.optional p Dot
4637-
(* dot is ignored *)
4638-
in
46394601
let attrs = doc_attr @ parse_attributes p in
46404602
match p.Parser.token with
46414603
| Tilde -> (

0 commit comments

Comments
 (0)