E3015#
The parameter already has default value None
.
In MoonBit, the optional parameter has one of the two following forms:
Optional parameter with default value:
fn f(a~ : Int = 0) -> Unit { // ... }
Optional parameter with no default value. In this case, when the parameter is not provided, it is
None
by default.fn f(a? : Int) -> Unit { // a has type Int? // ... }
Therefore, if the optional parameter has a default value of None
, it is redundant and should be removed.
Erroneous example#
fn f(a? : Int = None) -> Unit { // Error: The parameter a? already has default value `None`.
println(a)
}
Suggestion#
Remove the = None
part from the optional parameter.
fn f(a? : Int) -> Unit {
println(a)
}