aboutsummaryrefslogtreecommitdiff
path: root/boot/type_check.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-30 22:36:32 +0200
committerEugen Wissner <belka@caraus.de>2026-08-30 22:36:32 +0200
commit26a1b9ad9f347315bc14f2bf3ee064ede51794fc (patch)
tree64ecb7c41cb4b3f26ccbd216197c667d5cd8d8bd /boot/type_check.cc
parentdbca249757a98d6d56e23db43baa93ad30a91709 (diff)
downloadelna-26a1b9ad9f347315bc14f2bf3ee064ede51794fc.tar.gz
Fix record constructor for base records
Diffstat (limited to 'boot/type_check.cc')
-rw-r--r--boot/type_check.cc19
1 files changed, 9 insertions, 10 deletions
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<type_mismatch_error>(
- initializer.value().position(), initializer.value().type_decoration, type_mismatch_error::expected_type{field_type});
- }
- break;
- }
+ add_error<type_mismatch_error>(
+ initializer.value().position(), initializer.value().type_decoration,
+ type_mismatch_error::expected_type{field_type});
}
}
}