Skip to content

Commit 343e2d8

Browse files
committed
fix(name resolution): glob importing was broken and expected names to be fully qualified from the get go
1 parent f0ed405 commit 343e2d8

File tree

2 files changed

+4
-4
lines changed
  • include/Ark/Compiler/NameResolution
  • tests/unittests/resources/NameResolutionSuite/basic

2 files changed

+4
-4
lines changed

include/Ark/Compiler/NameResolution/StaticScope.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace Ark::internal
8282
[[nodiscard]] inline virtual bool isGlob() const { return false; }
8383
[[nodiscard]] inline virtual std::string prefix() const { return ""; }
8484
[[nodiscard]] inline virtual bool hasSymbol(const std::string&) const { return false; }
85-
[[nodiscard]] inline virtual bool recursiveHasSymbol(const std::string&) const { return false; }
85+
[[nodiscard]] inline virtual bool recursiveHasSymbol(const std::string&) { return false; }
8686

8787
private:
8888
std::unordered_set<Declaration> m_vars {};
@@ -128,9 +128,9 @@ namespace Ark::internal
128128
[[nodiscard]] inline bool isGlob() const override { return m_is_glob; }
129129
[[nodiscard]] inline std::string prefix() const override { return m_namespace; }
130130
[[nodiscard]] inline bool hasSymbol(const std::string& symbol) const override { return std::ranges::find(m_symbols, symbol) != m_symbols.end(); }
131-
[[nodiscard]] inline bool recursiveHasSymbol(const std::string& symbol) const override
131+
[[nodiscard]] inline bool recursiveHasSymbol(const std::string& symbol) override
132132
{
133-
if (hasSymbol(symbol))
133+
if (hasSymbol(symbol) || (isGlob() && get(symbol, false).has_value()))
134134
return true;
135135
for (const auto& saved_scope : m_additional_namespaces)
136136
{

tests/unittests/resources/NameResolutionSuite/basic/a.ark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
(let b_foo_ok (= "aa aaa" (b:foo "aa" "aaa")))
1111

12-
(let c_ok (and (= "c:egg" c:egg) (= "c:bacon" c:bacon)))
12+
(let c_ok (and (= "c:egg" egg) (= "c:bacon" bacon)))
1313

1414
(let d_ok (= "d:lamp" lamp))

0 commit comments

Comments
 (0)