diff options
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/name_analysis.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/boot/name_analysis.cc b/boot/name_analysis.cc index cfc4e35..48251cd 100644 --- a/boot/name_analysis.cc +++ b/boot/name_analysis.cc @@ -51,8 +51,7 @@ namespace elna::boot return "Symbol '" + identifier + "' has been already defined"; } - std::optional<std::pair<std::string, source_position>> - redefinition_error::note() const + std::optional<std::pair<std::string, source_position>> redefinition_error::note() const { if (original.has_value() && original->start().available()) { @@ -61,6 +60,16 @@ namespace elna::boot return std::nullopt; } + const_array_error::const_array_error(const source_position position) + : error(position) + { + } + + std::string const_array_error::what() const + { + return "const must be written before the array size, not after"; + } + // Members of a constant aggregate are constant themselves. static type qualify_member_type(const type& element, const type& aggregate) { @@ -176,9 +185,12 @@ namespace elna::boot void name_analysis_visitor::visit(array_type_expression *expression) { walking_visitor::visit(expression); - auto result_type = std::make_shared<array_type>(this->current_type, expression->size); - this->current_type = type(result_type); + if (this->current_type.get<constant_type>() != nullptr) + { + add_error<const_array_error>(expression->position()); + } + this->current_type = type(std::make_shared<array_type>(this->current_type, expression->size)); } /** |
