Removed invalid statement

This commit is contained in:
2026-05-21 11:07:49 +02:00
parent 2fcb8c3831
commit 9da4a50ef5
4 changed files with 3 additions and 21 deletions
-8
View File
@@ -76,14 +76,6 @@ visibility = { "pub" ~ ("(" ~ static_path ~ ")")? }
mutable = { "mut" }
var = { "var" }
// ======================================================
// ERROR RECOVERY
// ======================================================
unexpected_statement = {
(!(semicolon | "}" | statement) ~ ANY)+
}
// ======================================================
// GENERICS
// ======================================================
+1 -1
View File
@@ -78,7 +78,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Expression {
Rule::static_path => ast_expr!(Expression::Path(pair.try_into())),
Rule::literal => ast_expr!(Expression::Literal(pair.try_into())),
Rule::expr_path => ast_expr!(Expression::Path(pair.try_into())),
Rule::statement | Rule::basic_stmt | Rule::control_flow | Rule::unexpected_statement => ast_expr!(
Rule::statement | Rule::basic_stmt | Rule::control_flow => ast_expr!(
Expression::Statement(pair.try_into().get_map(Box::new).map(Box::new))
),
+1 -10
View File
@@ -2,7 +2,7 @@ use crate::{
Rule,
ast::*,
ast_ensure, ast_expr,
error::{AstError, AstResult, ErrorCode, IntoErr, collect_recovered},
error::{AstError, AstResult, IntoErr, collect_recovered},
parser::listen_rule,
};
@@ -101,15 +101,6 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
.collect::<AstResult<'a, Vec<_>>>(),
)),
Rule::unexpected_statement => {
return Err(AstError {
span: pair.as_span(),
error_code: ErrorCode::InvalidStatement,
error_message: "Invalid Statement".to_string(),
recovered: None,
});
}
_ => AstError::bug_unimplemented(pair),
}
}