From 1e0f89df48ba10cdde80bd623b84e20fb48b977d Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 24 Jul 2026 21:28:33 +0200 Subject: Accept any constant types in case labels --- boot/name_analysis.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'boot/name_analysis.cc') diff --git a/boot/name_analysis.cc b/boot/name_analysis.cc index 1e224da..07f6d31 100644 --- a/boot/name_analysis.cc +++ b/boot/name_analysis.cc @@ -303,7 +303,7 @@ namespace elna::boot * Collects field names from a record type recursively, base first. */ static void collect_field_names(const type& composite_type, - std::map& names) + ordered_map& names) { auto record = resolve_underlying_type(composite_type).get(); if (record == nullptr) @@ -316,24 +316,25 @@ namespace elna::boot } for (auto& field : record->fields) { - names.insert({ field.first, field_origin{ .declaration = std::nullopt, .base_type = composite_type } }); + names.insert(field.first, field_origin{ .declaration = std::nullopt, .base_type = composite_type }); } } - std::vector name_analysis_visitor::build_composite_type( + ordered_map name_analysis_visitor::build_composite_type( const std::vector& fields, - std::map& field_names, + ordered_map& field_names, const type& aggregate) { - std::vector result; + ordered_map result; for (const auto& field : fields) { field.second->accept(this); for (const auto& field_name : field.first) { - auto existing = field_names.find(field_name.name()); - if (existing != field_names.end()) + auto [existing, inserted] = field_names.insert(field_name.name(), + field_origin{ .declaration = field.second->position(), .base_type = type() }); + if (!inserted) { std::optional base_name; @@ -351,9 +352,7 @@ namespace elna::boot } else { - field_names.insert({ field_name.name(), - field_origin{ .declaration = field.second->position(), .base_type = type() } }); - result.emplace_back(field_name.name(), this->current_type); + result.insert(field_name.name(), this->current_type); } } } @@ -394,7 +393,7 @@ namespace elna::boot result_type = std::make_shared(); } - std::map field_names; + ordered_map field_names; collect_field_names(result_type->base, field_names); result_type->fields = build_composite_type(expression->fields, field_names, type(result_type)); -- cgit v1.2.3