From 26a1b9ad9f347315bc14f2bf3ee064ede51794fc Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 30 Aug 2026 22:36:32 +0200 Subject: Fix record constructor for base records --- boot/type_check.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'boot/type_check.cc') diff --git a/boot/type_check.cc b/boot/type_check.cc index 8f7a30f..abee91f 100644 --- a/boot/type_check.cc +++ b/boot/type_check.cc @@ -911,17 +911,16 @@ namespace elna::boot } for (const field_initializer& initializer : expression->field_initializers) { - for (const auto& [field_name, field_type]: record->fields) + // An initializer for an unknown field is already reported in name + // analysis; only check the value type when the field was found. + const type field_type = lookup_field(expression->type_decoration, initializer.name()); + + if (!field_type.empty() + && !is_assignable_from(field_type, initializer.value().type_decoration)) { - if (field_name == initializer.name()) - { - if (!is_assignable_from(field_type, initializer.value().type_decoration)) - { - add_error( - initializer.value().position(), initializer.value().type_decoration, type_mismatch_error::expected_type{field_type}); - } - break; - } + add_error( + initializer.value().position(), initializer.value().type_decoration, + type_mismatch_error::expected_type{field_type}); } } } -- cgit v1.2.3