Add scope level to return statement
This commit is contained in:
parent
a35add07db
commit
7bca803136
2 changed files with 2 additions and 0 deletions
|
|
@ -35,6 +35,7 @@ namespace pslang::ast
|
|||
// can be null, which means "return unit"
|
||||
expression_ptr value;
|
||||
ast::location location;
|
||||
std::size_t level = 0;
|
||||
};
|
||||
|
||||
using statement_impl = std::variant<
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ namespace pslang::parser
|
|||
{
|
||||
if (in_function_scope == 0)
|
||||
throw parse_error("Return statement outside of function scope", return_statement->location);
|
||||
return_statement->level = stack.size() - in_function_scope;
|
||||
current_statement_list(location)->statements.push_back(std::move(statement.statement));
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue