compiler, common, testing: Support For Checking For Invalid Statements

Add support functions to check whether a (block of) statement(s) contains
any statements that should not appear in that block (e.g., switch in
an action).

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-20 03:25:58 -04:00
parent a3a06efdb4
commit 5bc9db9aca
2 changed files with 80 additions and 0 deletions
+22
View File
@@ -351,3 +351,25 @@ extension Argument: Compilable {
}
}
}
func ContainsInvalidStatements(
statement: EvaluatableStatement, invalids: [EvaluatableStatement.Type]
) -> Bool {
for es in invalids {
if type(of: statement) == es {
return true
}
}
return false
}
func ContainsInvalidStatements(block: BlockStatement, invalids: [EvaluatableStatement.Type]) -> Bool {
return block.statements.contains() { statement in
for es in invalids {
if type(of: statement) == es {
return true
}
}
return false
}
}