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:
@@ -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()!)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user