[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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue