Fixed block statements

This commit is contained in:
2026-05-22 03:00:43 +02:00
parent b7cfa9fbe6
commit d33763be2e
4 changed files with 23 additions and 7 deletions
+10 -1
View File
@@ -11,7 +11,6 @@ pub struct Block(
#[derive(Debug, Clone, Serialize)]
pub enum Statement {
Block(Block),
VarDecl(VarDeclStmt),
If {
initial: StatementBranch,
else_if: Vec<StatementBranch>,
@@ -32,6 +31,7 @@ pub enum Statement {
},
Match(Expression, Vec<(Vec<Pattern>, Expression)>),
VarDecl(VarDeclStmt),
Return(Option<Expression>),
Break,
Continue,
@@ -55,3 +55,12 @@ pub struct StatementBranch {
pub condition: Expression,
pub body: Box<Statement>,
}
impl Statement {
pub fn is_block(&self) -> bool {
match self {
Self::VarDecl(_) | Self::Return(_) | Self::Break | Self::Continue => false,
_ => true,
}
}
}