[fine] Empty blocks generate nothing
This commit is contained in:
parent
8835d9eaf2
commit
56e4be9a5b
3 changed files with 18 additions and 5 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
10
fine/tests/expression/block.fine
Normal file
10
fine/tests/expression/block.fine
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// @concrete:
|
||||
// | File
|
||||
// | Block
|
||||
// | LeftBrace:'"{"'
|
||||
// | RightBrace:'"}"'
|
||||
// |
|
||||
|
||||
{}
|
||||
|
||||
// @type: 94 ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue