E4101#
Unsupported expression after the pipe operator.
This error occurs when the expression after the pipe operator (|>
) is not in a
supported form. The pipe operator allows you to chain function calls in a more
readable way, but only supports specific forms on its right-hand side.
The following forms are allowed after the pipe operator:
A single identifier (function name)
A regular function application (but not method calls)
A constructor name
A constructor application
错误示例#
type T Int
fn m(self: T, x: Int) -> Unit {
println(self._ + x)
}
pub fn f(t: T, x: Int) -> Unit {
x |> fn(x: Int) { println(x)}
// ^^^^^^^^^^^^^^^^^^^^^^^^ Error: Unsupported expression after the pipe operator.
x |> t.m()
// ^^^^ Error: Unsupported expression after the pipe operator.
}
建议#
To fix this error, you can change the invalid pipe expression to normal function or method application.
type T Int
fn m(self: T, x: Int) -> Unit {
println(self._ + x)
}
pub fn f(t: T, x: Int) -> Unit {
fn(x: Int) { println(x)}(x)
t.m(x)
}