Disable warnings for lacking ; for if-statements

This commit is contained in:
Sofia 2023-12-13 00:33:13 +02:00
parent 5084f21ff9
commit 47b9d7e044
3 changed files with 10 additions and 5 deletions

View File

@ -6,7 +6,7 @@ fn main() {
let hello = 32 + {
2 + 3
};
let beep = hello + fibonacci(15);
let beep = hello + fibonacci();
return beep;
}
@ -17,4 +17,4 @@ fn fibonacci(value: i32) -> i32 {
return 1;
}
return fibonacci(value - 1) + fibonacci(value - 2);
}
}

View File

@ -305,8 +305,13 @@ impl Parse for Block {
while !matches!(stream.peek(), Some(Token::BraceClose)) {
if let Some((r_type, e)) = return_stmt.take() {
println!("Oh no, does this statement lack ;");
dbg!(r_type, &e);
// Special list of expressions that are simply not warned about,
// if semicolon is missing.
if !matches!(&e, &Expression::IfExpr(_)) {
dbg!(r_type, &e);
println!("Oh no, does this statement lack ;");
}
statements.push(BlockLevelStatement::Expression(e));
}
let statement = stream.parse()?;

View File

@ -137,7 +137,7 @@ pub fn tokenize<T: Into<String>>(to_tokenize: T) -> Result<Vec<FullToken>, Error
w if w.is_whitespace() => continue,
// Comments
'/' if cursor.first() == Some('/') => {
while !matches!(cursor.first(), Some('\n')) {
while !matches!(cursor.first(), Some('\n') | None) {
cursor.next();
}
continue;