diff --git a/fine/src/semantics.rs b/fine/src/semantics.rs index 7d087afd..38075f79 100644 --- a/fine/src/semantics.rs +++ b/fine/src/semantics.rs @@ -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)) diff --git a/fine/tests/example_tests.rs b/fine/tests/example_tests.rs index d2bd33b2..ad296efd 100644 --- a/fine/tests/example_tests.rs +++ b/fine/tests/example_tests.rs @@ -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; } diff --git a/fine/tests/expression/block.fine b/fine/tests/expression/block.fine new file mode 100644 index 00000000..524514bc --- /dev/null +++ b/fine/tests/expression/block.fine @@ -0,0 +1,10 @@ +// @concrete: +// | File +// | Block +// | LeftBrace:'"{"' +// | RightBrace:'"}"' +// | + +{} + +// @type: 94 ()