From 558e0191ba5a5b0ab99825de7d7d2219387e559e Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Sat, 19 Apr 2025 18:36:42 +0000
Subject: [PATCH] constats variable type implementation

---
 src/Interpreter/IdentifierExpressionNode.hpp |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/Interpreter/IdentifierExpressionNode.hpp b/src/Interpreter/IdentifierExpressionNode.hpp
index c610f77..1846a9d 100644
--- a/src/Interpreter/IdentifierExpressionNode.hpp
+++ b/src/Interpreter/IdentifierExpressionNode.hpp
@@ -14,11 +14,17 @@
     explicit IdentifierExpressionNode(std::string name) : name_(std::move(name)) {}
 
     Symbols::Value evaluate(Interpreter & /*interpreter*/) const override {
-        const auto ns = Symbols::SymbolContainer::instance()->currentScopeName() + ".variables";
-        if (Symbols::SymbolContainer::instance()->exists(name_, ns)) {
-            return Symbols::SymbolContainer::instance()->get(ns, name_)->getValue();
+        auto * sc = Symbols::SymbolContainer::instance();
+        const std::string base_ns  = sc->currentScopeName();
+        const std::string var_ns   = base_ns + ".variables";
+        if (sc->exists(name_, var_ns)) {
+            return sc->get(var_ns, name_)->getValue();
         }
-        throw std::runtime_error("Variable " + name_ + " does not exist in ns: " + ns);
+        const std::string const_ns = base_ns + ".constants";
+        if (sc->exists(name_, const_ns)) {
+            return sc->get(const_ns, name_)->getValue();
+        }
+        throw std::runtime_error("Identifier '" + name_ + "' not found in namespace: " + base_ns);
     }
 
     std::string toString() const override { return name_; }

--
Gitblit v1.9.3