Skip to content

Commit 66723ba

Browse files
authored
Remove pipe last (|>) syntax (#7512)
1 parent 893f19f commit 66723ba

File tree

433 files changed

+6163
-6215
lines changed

Some content is hidden

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

433 files changed

+6163
-6215
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- Allow oneliner formatting when including module with single type alias. https://github.com/rescript-lang/rescript/pull/7502
3030
- Improve error messages for JSX type mismatches, passing objects where record is expected, passing array literal where tuple is expected, and more. https://github.com/rescript-lang/rescript/pull/7500
3131
- Show in error messages when coercion can be used to fix a type mismatch. https://github.com/rescript-lang/rescript/pull/7505
32+
- Remove deprecated pipe last (|>) syntax. https://github.com/rescript-lang/rescript/pull/7512
3233

3334
# 12.0.0-alpha.13
3435

analysis/reanalyze/src/Exception.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,6 @@ let traverseAst () =
304304
let exceptions = [arg] |> raiseArgs in
305305
currentEvents := {Event.exceptions; loc; kind = Raises} :: !currentEvents;
306306
arg |> snd |> iterExprOpt self
307-
| Texp_apply
308-
{
309-
funct = {exp_desc = Texp_ident (atat, _, _)};
310-
args = [arg; (_lbl1, Some {exp_desc = Texp_ident (callee, _, _)})];
311-
}
312-
when (* Exn(...) |> raise *)
313-
atat |> Path.name = "Pervasives.|>" && callee |> Path.name |> isRaise
314-
->
315-
let exceptions = [arg] |> raiseArgs in
316-
currentEvents := {Event.exceptions; loc; kind = Raises} :: !currentEvents;
317-
arg |> snd |> iterExprOpt self
318307
| Texp_apply {funct = {exp_desc = Texp_ident (callee, _, _)} as e; args} ->
319308
let calleeName = Path.name callee in
320309
if calleeName |> isRaise then

compiler/syntax/src/res_comments_table.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,9 +1483,8 @@ and walk_expression expr t comments =
14831483
txt =
14841484
Longident.Lident
14851485
( ":=" | "||" | "&&" | "==" | "===" | "<" | ">" | "!="
1486-
| "!==" | "<=" | ">=" | "|>" | "+" | "+." | "-" | "-."
1487-
| "++" | "^" | "*" | "*." | "/" | "/." | "**" | "->"
1488-
| "<>" );
1486+
| "!==" | "<=" | ">=" | "+" | "+." | "-" | "-." | "++"
1487+
| "^" | "*" | "*." | "/" | "/." | "**" | "->" | "<>" );
14891488
};
14901489
};
14911490
args = [(Nolabel, operand1); (Nolabel, operand2)];

compiler/syntax/src/res_core.ml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,25 +2186,9 @@ and parse_binary_expr ?(context = OrdinaryExpr) ?a p prec =
21862186
let b = parse_binary_expr ~context p token_prec in
21872187
let loc = mk_loc a.Parsetree.pexp_loc.loc_start b.pexp_loc.loc_end in
21882188
let expr =
2189-
match (token, b.pexp_desc) with
2190-
| ( BarGreater,
2191-
Pexp_apply {funct = fun_expr; args; partial; transformed_jsx} ) ->
2192-
{
2193-
b with
2194-
pexp_desc =
2195-
Pexp_apply
2196-
{
2197-
funct = fun_expr;
2198-
args = args @ [(Nolabel, a)];
2199-
partial;
2200-
transformed_jsx;
2201-
};
2202-
}
2203-
| BarGreater, _ -> Ast_helper.Exp.apply ~loc b [(Nolabel, a)]
2204-
| _ ->
2205-
Ast_helper.Exp.apply ~loc
2206-
(make_infix_operator p token start_pos end_pos)
2207-
[(Nolabel, a); (Nolabel, b)]
2189+
Ast_helper.Exp.apply ~loc
2190+
(make_infix_operator p token start_pos end_pos)
2191+
[(Nolabel, a); (Nolabel, b)]
22082192
in
22092193
Parser.eat_breadcrumb p;
22102194
loop expr)

compiler/syntax/src/res_parsetree_viewer.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ let operator_precedence operator =
280280
| "&&" -> 3
281281
| "^" -> 4
282282
| "&" -> 5
283-
| "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" | "|>" -> 6
283+
| "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" -> 6
284284
| "<<" | ">>" | ">>>" -> 7
285285
| "+" | "+." | "-" | "-." | "++" -> 8
286286
| "*" | "*." | "/" | "/." | "%" -> 9
@@ -317,8 +317,8 @@ let is_unary_bitnot_expression expr =
317317
let is_binary_operator operator =
318318
match operator with
319319
| ":=" | "||" | "&&" | "==" | "===" | "<" | ">" | "!=" | "!==" | "<=" | ">="
320-
| "|>" | "+" | "+." | "-" | "-." | "++" | "*" | "*." | "/" | "/." | "**"
321-
| "->" | "<>" | "%" | "&" | "^" | "<<" | ">>" | ">>>" ->
320+
| "+" | "+." | "-" | "-." | "++" | "*" | "*." | "/" | "/." | "**" | "->"
321+
| "<>" | "%" | "&" | "^" | "<<" | ">>" | ">>>" ->
322322
true
323323
| _ -> false
324324

@@ -715,7 +715,7 @@ let is_single_pipe_expr expr =
715715
match expr.pexp_desc with
716716
| Pexp_apply
717717
{
718-
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("->" | "|>")}};
718+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "->"}};
719719
args = [(Nolabel, _operand1); (Nolabel, _operand2)];
720720
} ->
721721
true
@@ -724,7 +724,7 @@ let is_single_pipe_expr expr =
724724
match expr.pexp_desc with
725725
| Pexp_apply
726726
{
727-
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("->" | "|>")}};
727+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "->"}};
728728
args = [(Nolabel, operand1); (Nolabel, _operand2)];
729729
}
730730
when not (is_pipe_expr operand1) ->

compiler/syntax/src/res_printer.ml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3753,13 +3753,10 @@ and print_unary_expression ~state expr cmt_tbl =
37533753
and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
37543754
let print_binary_operator ~inline_rhs operator =
37553755
let spacing_before_operator =
3756-
if operator = "->" then Doc.soft_line
3757-
else if operator = "|>" then Doc.line
3758-
else Doc.space
3756+
if operator = "->" then Doc.soft_line else Doc.space
37593757
in
37603758
let spacing_after_operator =
37613759
if operator = "->" then Doc.nil
3762-
else if operator = "|>" then Doc.space
37633760
else if inline_rhs then Doc.space
37643761
else Doc.line
37653762
in
@@ -3930,10 +3927,7 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
39303927
match expr.pexp_desc with
39313928
| Pexp_apply
39323929
{
3933-
funct =
3934-
{
3935-
pexp_desc = Pexp_ident {txt = Longident.Lident (("->" | "|>") as op)};
3936-
};
3930+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("->" as op)}};
39373931
args = [(Nolabel, lhs); (Nolabel, rhs)];
39383932
}
39393933
when not
@@ -3952,8 +3946,6 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
39523946
(match (lhs_has_comment_below, op) with
39533947
| true, "->" -> Doc.concat [Doc.soft_line; Doc.text "->"]
39543948
| false, "->" -> Doc.text "->"
3955-
| true, "|>" -> Doc.concat [Doc.line; Doc.text "|> "]
3956-
| false, "|>" -> Doc.text " |> "
39573949
| _ -> Doc.nil);
39583950
rhs_doc;
39593951
])

compiler/syntax/src/res_scanner.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,6 @@ let rec scan scanner =
820820
| '|' ->
821821
next2 scanner;
822822
Token.Lor
823-
| '>' ->
824-
next2 scanner;
825-
Token.BarGreater
826823
| _ ->
827824
next scanner;
828825
Token.Bar)

compiler/syntax/src/res_token.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ type t =
9494
| TemplateTail of string * Lexing.position
9595
| TemplatePart of string * Lexing.position
9696
| Backtick
97-
| BarGreater
9897
| Try
9998
| DocComment of Location.t * string
10099
| ModuleComment of Location.t * string
@@ -109,7 +108,7 @@ let precedence = function
109108
| Caret -> 4
110109
| Band -> 5
111110
| Equal | EqualEqual | EqualEqualEqual | LessThan | GreaterThan | BangEqual
112-
| BangEqualEqual | LessEqual | GreaterEqual | BarGreater ->
111+
| BangEqualEqual | LessEqual | GreaterEqual ->
113112
6
114113
| LeftShift | RightShift | RightShiftUnsigned -> 7
115114
| Plus | PlusDot | Minus | MinusDot | PlusPlus -> 8
@@ -213,7 +212,6 @@ let to_string = function
213212
| TemplatePart (text, _) -> text ^ "${"
214213
| TemplateTail (text, _) -> "TemplateTail(" ^ text ^ ")"
215214
| Backtick -> "`"
216-
| BarGreater -> "|>"
217215
| Try -> "try"
218216
| DocComment (_loc, s) -> "DocComment " ^ s
219217
| ModuleComment (_loc, s) -> "ModuleComment " ^ s

tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@
12161216
addValueReference OptArg.res:14:4 --> OptArg.res:14:21
12171217
addValueReference OptArg.res:14:4 --> OptArg.res:14:27
12181218
DeadOptionalArgs.addReferences twoArgs called with optional argNames: argNamesMaybe: OptArg.res:16:7
1219-
addValueReference OptArg.res:16:12 --> OptArg.res:14:4
1219+
addValueReference OptArg.res:16:10 --> OptArg.res:14:4
12201220
addValueReference OptArg.res:18:4 --> OptArg.res:18:17
12211221
addValueReference OptArg.res:18:4 --> OptArg.res:18:14
12221222
addValueReference OptArg.res:18:4 --> OptArg.res:18:24
@@ -2510,7 +2510,7 @@ File References
25102510
Live Value +OptArg.+fourArgs: 1 references (OptArg.res:26:4) [0]
25112511
Live Value +OptArg.+wrapOneArg: 1 references (OptArg.res:22:7) [0]
25122512
Live Value +OptArg.+oneArg: 1 references (OptArg.res:20:4) [0]
2513-
Live Value +OptArg.+twoArgs: 1 references (OptArg.res:16:12) [0]
2513+
Live Value +OptArg.+twoArgs: 1 references (OptArg.res:16:10) [0]
25142514
Live Value +OptArg.+threeArgs: 2 references (OptArg.res:11:7, OptArg.res:12:7) [0]
25152515
Live Value +OptArg.+bar: 2 references (OptArg.res:7:7, OptArg.resi:2:0) [0]
25162516
Live Value +OptArg.+foo: 1 references (OptArg.res:5:7) [0]

tests/analysis_tests/tests-reanalyze/deadcode/src/OptArg.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Js.log(threeArgs(~a=4, 1))
1313

1414
let twoArgs = (~a=1, ~b=2, c) => a + b + c
1515

16-
Js.log(1 |> twoArgs)
16+
Js.log(1->twoArgs)
1717

1818
let oneArg = (~a=1, ~z, b) => a + b
1919

tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ type u3 = (. int, string, int) => string
1414
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
26-
let curried3 = (x, y, z) => (x |> string_of_int) ++ (y ++ (z |> string_of_int))
26+
let curried3 = (x, y, z) => (x -> string_of_int) ++ (y ++ (z -> string_of_int))
2727

2828
@genType
29-
let callback = cb => cb() |> string_of_int
29+
let callback = cb => cb() -> string_of_int
3030

3131
type auth = {login: unit => string}
3232
type authU = {loginU: (. unit) => string}

tests/analysis_tests/tests-reanalyze/deadcode/src/Unison.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ let rec toString = (~width, stack) =>
2727
switch stack {
2828
| Cons({break, doc}, stack) =>
2929
switch break {
30-
| IfNeed => (fits(width, stack) ? "fits " : "no ") ++ (stack |> toString(~width=width - 1))
31-
| Never => "never " ++ (doc ++ (stack |> toString(~width=width - 1)))
32-
| Always => "always " ++ (doc ++ (stack |> toString(~width=width - 1)))
30+
| IfNeed => (fits(width, stack) ? "fits " : "no ") ++ (stack -> toString(~width=width - 1))
31+
| Never => "never " ++ (doc ++ (stack -> toString(~width=width - 1)))
32+
| Always => "always " ++ (doc ++ (stack -> toString(~width=width - 1)))
3333
}
3434
| Empty => ""
3535
}

tests/analysis_tests/tests-reanalyze/deadcode/src/exception/TestYojson.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let foo = x => Yojson.Basic.from_string(x)
44
let bar = (str, json) =>
55
switch {
66
open Yojson.Basic.Util
7-
json |> member(str)
7+
member(str, json)
88
} {
99
| j => j
1010
| exception Yojson.Basic.Util.Type_error("a", d) when d == json => json

tests/syntax_tests/data/conversion/reason/attributes.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Js.log
1717
type t
1818
@new external make: unit => t = "DOMParser"
1919

20-
Js.log(make() |> parseHtmlFromString("sdsd"))
20+
Js.log(make()->parseHtmlFromString("sdsd"))

tests/syntax_tests/data/conversion/reason/expected/attributes.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Js.log
1717
type t
1818
@new external make: unit => t = "DOMParser"
1919

20-
Js.log(parseHtmlFromString("sdsd", make()))
20+
Js.log(make()->parseHtmlFromString("sdsd"))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
let photo = Array.get(_, 0)(filterNone(pricedRoom["room"]["photos"]))
1+
let photo = pricedRoom["room"]["photos"]->filterNone->Array.get(_, 0)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
let photo = pricedRoom["room"]["photos"] |> filterNone |> Array.get(_, 0)
1+
let photo = pricedRoom["room"]["photos"]->filterNone->Array.get(_, 0)

tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ let gridLengthToJs = x =>
14921492
}
14931493

14941494
let string_of_dimensions = dimensions =>
1495-
dimensions |> List.map(gridLengthToJs) |> String.concat(" ")
1495+
dimensions->List.map(gridLengthToJs)->String.concat(" ")
14961496

14971497
let gridTemplateColumns = dimensions => D("gridTemplateColumns", string_of_dimensions(dimensions))
14981498

@@ -1699,13 +1699,13 @@ let fontFace = (~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?,
16991699
let fontStyle = Js.Option.map((. value) => FontStyle.toString(value), fontStyle)
17001700
let src =
17011701
src
1702-
|> List.map(x =>
1702+
->List.map(x =>
17031703
switch x {
17041704
| #localUrl(value) => `local("$(value)")`
17051705
| #url(value) => `url("$(value)")`
17061706
}
17071707
)
1708-
|> String.concat(", ")
1708+
->String.concat(", ")
17091709

17101710
let fontStyle = Belt.Option.mapWithDefault(fontStyle, "", s => "font-style: " ++ (s ++ ";"))
17111711
let fontWeight = Belt.Option.mapWithDefault(fontWeight, "", w =>

0 commit comments

Comments
 (0)