Improve warning message for UnusedVariable

This commit is contained in:
KtorZ 2023-03-16 19:14:17 +01:00 committed by Lucas
parent 45575cae96
commit 5d3816e984
1 changed files with 12 additions and 3 deletions

View File

@ -1382,9 +1382,18 @@ pub enum Warning {
},
#[error("I came across an unused variable.\n")]
#[diagnostic(help(
"No big deal, but you might want to remove it to get rid of that warning."
))]
#[diagnostic(help("{}", formatdoc! {
r#"No big deal, but you might want to remove it to get rid of that warning.
You should also know that, unlike in typical imperative languages, unused let-bindings are {fully_ignored} in Aiken.
They will not produce any side-effect (such as error calls). Programs with or without unused variables are semantically equivalent.
If you do want to enforce some side-effects, use {keyword_expect} instead of {keyword_let}.
"#,
fully_ignored = "fully_ignored".if_supports_color(Stderr, |s| s.bold()),
keyword_expect = "expect".if_supports_color(Stderr, |s| s.yellow()),
keyword_let = "let".if_supports_color(Stderr, |s| s.yellow()),
}))]
#[diagnostic(code("unused::variable"))]
UnusedVariable {
#[label("unused")]