Skip to content

Commit

Permalink
Improve warning message for UnusedVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ authored and rvcas committed Mar 16, 2023
1 parent 45575ca commit 5d3816e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions crates/aiken-lang/src/tipo/error.rs
Expand Up @@ -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")]
Expand Down

0 comments on commit 5d3816e

Please sign in to comment.