From 5dcf95a20a1da52efa11109aeb8efb9835eec5f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Tue, 31 May 2022 15:23:02 +0200
Subject: [PATCH] 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'"
---
 src/language/ast/ASTSymbolInitializationChecker.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/language/ast/ASTSymbolInitializationChecker.cpp b/src/language/ast/ASTSymbolInitializationChecker.cpp
index 9ce181ca7..c3ae069cc 100644
--- a/src/language/ast/ASTSymbolInitializationChecker.cpp
+++ b/src/language/ast/ASTSymbolInitializationChecker.cpp
@@ -63,14 +63,13 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
     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");
 
-    i_symbol->attributes().setIsInitialized();
-
     auto& function_table = node.m_symbol_table->functionTable();
 
     uint64_t function_id      = std::get<uint64_t>(i_symbol->attributes().value());
     auto& function_descriptor = function_table[function_id];
     this->_checkSymbolInitialization(function_descriptor.definitionNode());
 
+    i_symbol->attributes().setIsInitialized();
   } else if (node.is_type<language::function_definition>()) {
     this->_checkSymbolInitialization(*node.children[1]);
   } else if (node.is_type<language::eq_op>()) {
-- 
GitLab