diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-10-09 00:52:27 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-10-09 00:52:27 +0200 |
| commit | 994e6c95929ad9551901d86617e4678920f8f357 (patch) | |
| tree | d12a438aa537ea8fb680161ec945e4a7a14af1de /boot/name_analysis.cc | |
| parent | ea902858825aac806cd282e6d5f02ec683a995e3 (diff) | |
| download | elna-994e6c95929ad9551901d86617e4678920f8f357.tar.gz | |
Strip away constness from literals and rvalues
Diffstat (limited to 'boot/name_analysis.cc')
| -rw-r--r-- | boot/name_analysis.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/boot/name_analysis.cc b/boot/name_analysis.cc index c82f211..c58b586 100644 --- a/boot/name_analysis.cc +++ b/boot/name_analysis.cc @@ -155,6 +155,8 @@ namespace elna::boot return "Duplicate 'const' qualifier is not allowed"; case constant_procedure: return "Procedure types are always constant, 'const' is not allowed"; + case constant_record_constructor: + return "Record constructor cannot have 'const' qualifier"; case module_entry: return "Program entry point should have no or one argument"; case enumeration_values: @@ -918,7 +920,12 @@ namespace elna::boot void resolving_visitor::visit(record_constructor_expression *expression) { - expression->type_decoration = resolve_type(expression->record_type()); + if (expression->record_type().is_constant() != nullptr) + { + add_error<declaration_format_error>(expression->record_type().position(), + declaration_format_error::kind::constant_record_constructor); + } + expression->type_decoration = unqualify(resolve_type(expression->record_type())); for (const field_initializer& initializer : expression->field_initializers) { @@ -936,7 +943,7 @@ namespace elna::boot void resolving_visitor::visit(array_constructor_expression *expression) { visit_all(this, expression->elements); - const type element_type = expression->elements.front()->type_decoration; + const type element_type = unqualify(expression->elements.front()->type_decoration); expression->type_decoration = type(std::make_shared<array_type>(element_type, expression->elements.size())); @@ -1012,11 +1019,11 @@ namespace elna::boot } else { - expression->type_decoration = expression->lhs().type_decoration; + expression->type_decoration = unqualify(expression->lhs().type_decoration); } break; default: - expression->type_decoration = expression->lhs().type_decoration; + expression->type_decoration = unqualify(expression->lhs().type_decoration); break; } this->current_type = type(); @@ -1033,7 +1040,7 @@ namespace elna::boot } else { - expression->type_decoration = expression->operand().type_decoration; + expression->type_decoration = unqualify(expression->operand().type_decoration); } this->current_type = type(); } @@ -1455,7 +1462,7 @@ namespace elna::boot declaration->initializer->accept(this); if (declaration->variable_type == nullptr) { - variable_type = declaration->initializer->type_decoration; + variable_type = unqualify(declaration->initializer->type_decoration); if (declaration->is_const) { variable_type = type(std::make_shared<constant_type>(variable_type)); @@ -1594,7 +1601,7 @@ namespace elna::boot declaration->initializer->accept(this); if (declaration->variable_type == nullptr) { - variable_type = declaration->initializer->type_decoration; + variable_type = unqualify(declaration->initializer->type_decoration); if (declaration->is_const) { variable_type = type(std::make_shared<constant_type>(variable_type)); |
