add support for (void) block expression

This commit is contained in:
2021-11-13 17:43:04 +01:00
parent e4bf292e47
commit 29b8c04700
6 changed files with 84 additions and 33 deletions

View File

@@ -577,6 +577,19 @@ fn tc_expression(context: &mut Context, expr: &mut ast::Expression) -> Result<()
context.block_stack.pop();
block.type_
}
ast::Expr::LabelBlock {
ref label,
ref mut block,
} => {
context.block_stack.push(label.clone());
tc_expression(context, block)?;
context.block_stack.pop();
if block.type_ != None {
// TODO: implement, requires branches to optionally provide values
return type_mismatch(None, &expr.span, block.type_, &block.span, context.source);
}
None
}
ast::Expr::Branch(ref label) => {
if !context.block_stack.contains(label) {
return missing_label(&expr.span, context.source);