add warning to if-statement in check mode

warning is shown if the condition of an
if statement can never be true or false,
and the user used the check command.
warnings are not shown when you use `mers run`.
This commit is contained in:
Mark
2024-08-29 15:48:01 +02:00
parent 385019e43c
commit 817ed25f96
5 changed files with 56 additions and 6 deletions

View File

@@ -97,6 +97,8 @@ pub enum EColor {
MaximumRuntimeExceeded,
InCodePositionLine,
Warning,
}
pub trait ETheme: ThemeGen<C = EColor, T = String> {}

View File

@@ -42,6 +42,10 @@ pub fn default_theme<C>(
_ => return None,
});
}
if let Warning = color {
// same color as runtime errors, because warnings are only displayed in `check` mode, where the program won't run.
return Some(yellow);
}
let hard_err = red;
let type_right = blue;
let type_wrong = magenta;
@@ -56,7 +60,7 @@ pub fn default_theme<C>(
drop(cyan_bright);
use EColor::*;
Some(match color {
Indent(_) => unreachable!(),
Indent(_) | Warning => unreachable!(),
// macros (#...)
WhitespaceAfterHashtag