From 5d3816e984e43705eea8cb789644a728191e0d78 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Thu, 16 Mar 2023 19:14:17 +0100 Subject: [PATCH] Improve warning message for UnusedVariable --- crates/aiken-lang/src/tipo/error.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/aiken-lang/src/tipo/error.rs b/crates/aiken-lang/src/tipo/error.rs index 8ef7196dc..fc7f3833c 100644 --- a/crates/aiken-lang/src/tipo/error.rs +++ b/crates/aiken-lang/src/tipo/error.rs @@ -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")]