Don't allow recursive structs
This commit is contained in:
parent
ddf6d55c54
commit
56c8214f36
1 changed files with 9 additions and 2 deletions
|
|
@ -194,8 +194,15 @@ namespace pslang::interpreter
|
|||
if (scope.contains(struct_definition.name))
|
||||
throw std::runtime_error("Identifier \"" + struct_definition.name + "\" is already defined in this scope");
|
||||
|
||||
auto & result = scope.structs[struct_definition.name];
|
||||
result.fields = struct_definition.fields;
|
||||
struct_data result;
|
||||
for (auto const & field : struct_definition.fields)
|
||||
{
|
||||
result.fields.push_back({
|
||||
.name = field.name,
|
||||
.type = std::make_unique<type::type>(resolve_type(context, *field.type)),
|
||||
});
|
||||
}
|
||||
scope.structs[struct_definition.name] = std::move(result);
|
||||
}
|
||||
|
||||
void exec_impl(context & context, ast::statement_list_ptr const & statements)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue