E0027#
Warning name: deprecated_syntax
The syntax is deprecated. Please refer to the warning message on the reason and potential fix.
For example, one deprecated usage is using constructors as functions. Instead, wrap the constructor call in a lambda.
Erroneous example#
enum Message {
Add(String)
} derive(Show)
fn perform[T](message : (T) -> Message, produce : () -> T) -> Message {
//
// Warning: The syntax fn f[..] for declaring polymorphic function is
// deprecated. Use fn[..] f instead.
message(produce())
}
fn main {
println(perform(Add, fn() { "Hello, world!" }))
// ^^^
// Warning: Using constructor as function directly is
// deprecated. Use the partial application syntax instead
}
Suggestion#
Migrate the code according to the warning message. In this case, the code should be changed to use a lambda.
///|
enum Message {
Add(String)
}
///|
fn[T] perform(message : (T) -> Message, produce : () -> T) -> Message {
message(produce())
}
///|
fn main {
match perform(x => Add(x), fn() { "Hello, world!" }) {
Add(message) => println(message)
}
}