diff --git a/CHANGELOG.md b/CHANGELOG.md index c9527d60..eecc6eef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Fixed +- **aiken-lang**: Explain discards and expect a bit better in the unused var warning - **aiken-lang**: Fix expect \_ = ... not including the cast from data logic if the type is data and right hand has a type annotation - **aiken-lang**: Fix for the final clause of a when expecting another clause afterwards in nested list cases. diff --git a/crates/aiken-lang/src/tipo/error.rs b/crates/aiken-lang/src/tipo/error.rs index dd655eed..7b199fc4 100644 --- a/crates/aiken-lang/src/tipo/error.rs +++ b/crates/aiken-lang/src/tipo/error.rs @@ -1426,16 +1426,17 @@ pub enum Warning { name.if_supports_color(Stderr, |s| s.purple()) )] #[diagnostic(help("{}", formatdoc! { - r#"No big deal, but you might want to remove it to get rid of that warning. + r#"No big deal, but you might want to remove it or use a discard {name} 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}. + If you do want to enforce some side-effects, use {keyword_expect} with a discard {name} 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()), + name = format!("_{name}").if_supports_color(Stderr, |s| s.yellow()) }))] #[diagnostic(code("unused::variable"))] UnusedVariable {