Problem
TypeChecker.checkStatement handles ~16 statement kinds and routes everything else to else => {} — including ReturnStmt, MatchStmt, BlockStmt, AssertStmt, TraitDecl, ImplDecl and ExtendDecl. A function declared -> i32 can therefore return a String, and anything inside a nested {} / unsafe {} block is unchecked. The function-body loop carries no return-type context. A second checker in codegen does implement checkReturnStmt, but native_codegen.typeCheck() has no callers.
Evidence (origin/main @ d4b219507)
packages/types/src/type_system.zig:1414-1942packages/types/src/type_system.zig:1545-1555packages/codegen/src/type_checker.zig:636-655packages/codegen/src/native_codegen.zig:1079
Scope
- Handle every statement kind in
checkStatement(no silentelse => {}). - Track the enclosing function's declared return type and check each
returnagainst it. - Fold the useful parts of
packages/codegen/src/type_checker.zigintopackages/typesand delete the dead copy.
Acceptance criteria
home checkrejects a wrong-typedreturn.- Type errors inside
{ ... }andunsafe { ... }blocks are reported. - A non-bool
assertcondition is rejected. - An
implmethod whose signature differs from its trait declaration is rejected. - Each case has a negative regression test.
Links
Part of #814.