aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
Diffstat (limited to 'boot')
-rw-r--r--boot/name_analysis.cc21
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));