E2000

E2000#

The usage of function (type, trait, etc.) is flagged with alert. Usually, alert message comes with a alert kind and a detailed description of the alert. If you are using the function from a library, these alerts are set by the library author to provide some more information on the usage of the function

There are some common alerts that you may encounter:

  • deprecated: indicates the function (or type, trait, etc.) is deprecated and should not be used. You should migrate to new APIs.

  • unsafe: indicates this API may panic, have internal invariants, or have undefined behavior under some circumstances. The concrete semantics of this kind of alerts may be different across packages, and please consult the documentation or the author of these packages for further details.

Erroneous example#

/// @alert deprecated "Use `greet` instead"
fn greeting() -> String {
  "Hello!"
}

fn greet(name~ : String = "") -> String {
  if name != "" {
    "Hello!"
  } else {
    "Hello, \{name}!"
  }
}

fn main {
  println(greeting())
  //      ^~~~~~~~ Warning (Alert deprecated): Use `greet` instead(2000)
}

Suggestion#

One way to fix the alert, is to change your code as suggested by the message (like deprecated):

// ... code in the example above ...
fn main {
  println(greet(name="world"))
}

If you clearly know what you are doing and would like to suppress the alert, you can change the moon.pkg.json file for packages where you would like to disable this kind of alert. For example:

{
  // ... other fields in the file
  "alert-list": "-deprecated"
}

Note

There is no way to disable alerts for a line/file.