···3535 JavaScript target, allowing for faster comparison in most cases.
3636 ([Surya Rose](https://github.com/GearsDatapacks))
37373838+- The use of pipes to turn the Gleam code `a |> b(c)` into `b(c)(a)` has been
3939+ deprecated.
4040+ ([Surya Rose](https://github.com/GearsDatapacks))
4141+3842### Build tool
39434044- The build tool now generates Hexdocs URLs using the new format of
···144144 // Without lifting purity tracking into the type system,
145145 // we have no idea whether it's pure or not!
146146 self.expr_typer.purity = self.expr_typer.purity.merge(Purity::Unknown);
147147+148148+ // This syntax is deprecated.
149149+ self.expr_typer
150150+ .problems
151151+ .warning(Warning::PipeIntoCallWhichReturnsFunction { location });
152152+147153 (
148154 PipelineAssignmentKind::FunctionCall,
149155 self.infer_apply_to_call_pipe(fun, arguments, location),
···11+---
22+source: compiler-core/src/type_/tests/warnings.rs
33+expression: "\npub fn main() {\n 1 |> wibble(2)\n}\n\nfn wibble(a) {\n fn(b) { #(a, b) }\n}\n"
44+---
55+----- SOURCE CODE
66+77+pub fn main() {
88+ 1 |> wibble(2)
99+}
1010+1111+fn wibble(a) {
1212+ fn(b) { #(a, b) }
1313+}
1414+1515+1616+----- WARNING
1717+warning: Deprecated pipe use
1818+ ┌─ /src/warning/wrn.gleam:3:8
1919+ │
2020+3 │ 1 |> wibble(2)
2121+ │ ^^^^^^^^^ This should have an extra set of parentheses
2222+2323+This use of pipelines is deprecated, as it creates ambiguity in pipe
2424+syntax. Currently `a |> b(c)` can desugar to either `b(a, c)` or `b(a)(c)`
2525+depending on the type of `b`. The latter syntax is deprecated, and should
2626+not be used.
2727+2828+Hint: Add an extra set of parentheses after the call, like `a |> b(c)()`
···14901490 extra_labels: vec![],
14911491 }),
14921492 },
14931493+14941494+ type_::Warning::PipeIntoCallWhichReturnsFunction { location } => Diagnostic {
14951495+ title: "Deprecated pipe use".into(),
14961496+ text: wrap(
14971497+ "This use of pipelines is deprecated, as it creates \
14981498+ambiguity in pipe syntax. Currently `a |> b(c)` can desugar to either `b(a, c)` or \
14991499+`b(a)(c)` depending on the type of `b`. The latter syntax is deprecated, and should \
15001500+not be used.",
15011501+ ),
15021502+ hint: Some(
15031503+ "Add an extra set of parentheses after the call, like `a |> b(c)()`".into(),
15041504+ ),
15051505+ level: diagnostic::Level::Warning,
15061506+ location: Some(Location {
15071507+ label: diagnostic::Label {
15081508+ text: Some("This should have an extra set of parentheses".into()),
15091509+ span: *location,
15101510+ },
15111511+ path: path.clone(),
15121512+ src: src.clone(),
15131513+ extra_labels: vec![],
15141514+ }),
15151515+ },
14931516 },
1494151714951518 Warning::EmptyModule { path: _, name } => Diagnostic {
···47474848- [x] Emits warning when used.
4949- [x] Formatter rewrites it to desired syntax.
5050+5151+## Piping into a call that returns a function
5252+5353+In Gleam v1, the syntax `a |> b(c)` is ambiguous; it can either mean `b(a, c)`
5454+or `b(a)(c)`. This makes code harder to reason about as it means that you cannot
5555+determine the meaning of pipe expressions without knowing the type of the called
5656+function.
5757+5858+In Gleam v2, we want to remove the second option, so `a |> b(c)` always desugars
5959+to `b(a, c)`, regardless of the types.
6060+6161+- [x] Emits warning when used.
6262+- [ ] Code action to rewrite to desired syntax