Add scope level to return statement

This commit is contained in:
Nikita Lisitsa 2025-12-22 23:51:41 +03:00
parent a35add07db
commit 7bca803136
2 changed files with 2 additions and 0 deletions

View file

@ -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<

View file

@ -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