E0031#

Warning name: unused_optional_argument

The optional argument is never supplied. If the optional argument is never supplied, then it can be safely removed from the parameter list and be used purely internally as a normal variable.

Erroneous example#

この警告はデフォルトでは無効です。moon.pkgwarnings フィールドで有効にできます:

moon.pkg#
warnings = "+unused_optional_argument"

pkgtype(kind: "executable")
main.mbt#
///|
fn f(opt? : Int = 4) -> Int {
  ignore(opt)
  0
}

///|
fn main {
  println(f())
  println(f())
}

Suggestion#

You can remove the optional argument, and use a local variable definition instead:

///|
fn f() -> Int {
  let opt = 4
  ignore(opt)
  0
}

///|
fn main {
  println(f())
  println(f())
}