E0032

E0032#

Warning name: unused_default_value

The default value of an optional argument is unused: every call site explicitly supplies a value. Remove the default value to make it a required labelled argument, keeping the ~ in its declaration.

Erroneous example#

This warning is turned off by default. Enable it with the warnings field in moon.pkg:

moon.pkg#
warnings = "+unused_default_value"

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

///|
fn main {
  println(f(opt=3))
  println(f(opt=3))
}

Suggestion#

Remove the default value to make the labelled argument required:

///|
fn f(opt~ : Int32) -> Int32 {
  ignore(opt)
  0
}

///|
fn main {
  println(f(opt=3))
  println(f(opt=3))
}