Refactor Expected Types During Compilation

By adding an expected type to the compilation context, it is
now possible for type checking to occur on keyset expressions
and return statements at the moment that they are being compiled.

Previously, it was necessary to tentatively compile them and then
typecheck afterward.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-10 00:59:11 -04:00
parent ad7e5a6f6d
commit b687454389
8 changed files with 112 additions and 115 deletions
+3 -1
View File
@@ -112,7 +112,9 @@ extension FunctionDeclaration: CompilableDeclaration {
}
let maybe_function_body = Parser.Statement.Compile(
node: currentChild!, withContext: context.update(newInstances: function_scope))
node: currentChild!,
withContext: context.update(newInstances: function_scope).update(
newExpectation: function_type))
guard case .Ok((let function_body, _)) = maybe_function_body else {
return .Error(maybe_function_body.error()!)
}