[fine] Empty blocks generate nothing

This commit is contained in:
John Doty 2024-01-06 11:00:31 -08:00
parent 8835d9eaf2
commit 56e4be9a5b
3 changed files with 18 additions and 5 deletions

View file

@ -347,10 +347,10 @@ impl<'a> Semantics<'a> {
return None;
}
// if tree.children.len() == 2 {
// // Empty blocks generate Nothing.
// return Some(Type::Nothing);
// }
if tree.children.len() == 2 {
// Empty blocks generate Nothing.
return Some(Type::Nothing);
}
// The type of the block is the type of the last expression.
// (But the last child is the closing brace probably?)
@ -359,6 +359,9 @@ impl<'a> Semantics<'a> {
let mut is_unreachable = false;
for i in 1..last_index {
// TODO: if `is_unreachable` here then we actually have
// unreachable code here! We should warn about it I guess.
is_unreachable = self
.type_of(tree.nth_tree(i)?)
.map(|t| matches!(t, Type::Unreachable))

View file

@ -16,7 +16,7 @@ fn rebase_concrete(source_path: &str, dump: &str) {
result.push_str(line);
result.push_str("\n");
if line == "// concrete:" {
if line == "// @concrete:" {
found_concrete_section = true;
break;
}

View file

@ -0,0 +1,10 @@
// @concrete:
// | File
// | Block
// | LeftBrace:'"{"'
// | RightBrace:'"}"'
// |
{}
// @type: 94 ()