dont crash on inline static value array

This commit is contained in:
ManDude
2022-08-13 14:40:33 +01:00
parent 9ce3f8e718
commit 8a13da3b59
+4 -3
View File
@@ -1052,7 +1052,7 @@ StaticResult Compiler::fill_static_inline_array(const goos::Object& form,
// get all arguments now
auto args = get_list_as_vector(rest);
if (args.size() < 4) {
throw_compiler_error(form, "new static boxed array must have type and min-size arguments");
throw_compiler_error(form, "new static inlined array must have type and min-size arguments");
}
auto content_type = parse_typespec(args.at(2), env);
s64 min_size = get_constant_integer_or_error(args.at(3), env);
@@ -1060,8 +1060,9 @@ StaticResult Compiler::fill_static_inline_array(const goos::Object& form,
auto inline_array_type = m_ts.make_inline_array_typespec(content_type);
auto deref_info = m_ts.get_deref_info(inline_array_type);
ASSERT(deref_info.can_deref);
ASSERT(!deref_info.mem_deref);
if (!deref_info.can_deref || deref_info.mem_deref) {
throw_compiler_error(form, "new static inline array of value types is currently not supported");
}
auto obj = std::make_unique<StaticStructure>(seg);
obj->set_offset(is_basic(content_type) ? 4 : 0);
obj->data.resize(length * deref_info.stride);