Skip to content
Snippets Groups Projects
Commit 5dcf95a2 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Fix function symbol initialization location to prevent recursion

The function symbol is now marked as initialized after checking that
the expression terms are all initialized.

Thus, now, the expression
```
let f: N->N, n -> f(2*n);
```
produced the expected error: "error: uninitialized symbol 'f'"
parent 13df8fc2
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
...@@ -63,14 +63,13 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node) ...@@ -63,14 +63,13 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
auto [i_symbol, found] = node.m_symbol_table->find(symbol, node.children[0]->begin()); auto [i_symbol, found] = node.m_symbol_table->find(symbol, node.children[0]->begin());
Assert(found, "unexpected error, should have been detected through declaration checking"); Assert(found, "unexpected error, should have been detected through declaration checking");
i_symbol->attributes().setIsInitialized();
auto& function_table = node.m_symbol_table->functionTable(); auto& function_table = node.m_symbol_table->functionTable();
uint64_t function_id = std::get<uint64_t>(i_symbol->attributes().value()); uint64_t function_id = std::get<uint64_t>(i_symbol->attributes().value());
auto& function_descriptor = function_table[function_id]; auto& function_descriptor = function_table[function_id];
this->_checkSymbolInitialization(function_descriptor.definitionNode()); this->_checkSymbolInitialization(function_descriptor.definitionNode());
i_symbol->attributes().setIsInitialized();
} else if (node.is_type<language::function_definition>()) { } else if (node.is_type<language::function_definition>()) {
this->_checkSymbolInitialization(*node.children[1]); this->_checkSymbolInitialization(*node.children[1]);
} else if (node.is_type<language::eq_op>()) { } else if (node.is_type<language::eq_op>()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment