mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:41:04 +01:00
Add handling for return types. (#2596)
This starts handling return types on functions, and comparing types with `return` statements. Note, errors remain poor because the type literal is currently associated with a builtin, losing the parse_node that specified it. This means we don't have the original source location to associate with, even though it may be helpful to point at the type in source. We could point at the signature overall, but my leaning is that we wouldn't want that long-term, so TODOs for now and may want to change a little about how the parse node is tracked once things are a little further along.
This commit is contained in:
@@ -168,9 +168,16 @@ class SemanticsParseTreeHandler {
|
||||
// node in blocks here.
|
||||
SemanticsNodeBlockStack params_or_args_stack_;
|
||||
|
||||
// Completed parameters that are held temporarily on a side-channel for a
|
||||
// function. This can't use node_stack_ because it has space for only one
|
||||
// value, whereas parameters return two values.
|
||||
llvm::SmallVector<std::pair<SemanticsNodeBlockId, SemanticsNodeBlockId>>
|
||||
finished_params_stack_;
|
||||
|
||||
// A stack of return scopes; i.e., targets for `return`. Inside a function,
|
||||
// this will be a FunctionDeclaration.
|
||||
llvm::SmallVector<SemanticsNodeId> return_scope_stack_;
|
||||
|
||||
// A stack for scope context.
|
||||
llvm::SmallVector<ScopeStackEntry> scope_stack_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user