lemonlang 0.0.4

an experimental, modern, purely safe, programming language.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::ast::{self};

use super::{context::scope::ScopeType, types::TypeId, Checker, TyResult};

impl Checker<'_> {
	pub fn check_block_stmt(&mut self, block: &mut ast::BlockStmt) -> TyResult<TypeId> {
		// todo: warn unreachable code
		self.ctx.enter_scope(ScopeType::new_block());
		let mut ret_type = TypeId::UNIT;
		for stmt in block.stmts.iter_mut() {
			self.ctx.flow.set_paths_return(stmt.ends_with_ret());
			ret_type = self.check_stmt(stmt)?;
		}
		self.ctx.exit_scope();
		Ok(ret_type)
	}
}