fix: clearer unused var warning closes #579
This commit is contained in:
parent
697de40376
commit
d633129ddf
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue