Skip to content

Commit f178f65

Browse files
committed
feat(name resolution): allow fqn if the scope is only exporting symbols
1 parent c424993 commit f178f65

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

include/Ark/Compiler/NameResolution/StaticScope.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <optional>
1717
#include <memory>
1818
#include <vector>
19+
#include <ranges>
1920
#include <unordered_set>
2021

2122
namespace Ark::internal
@@ -79,6 +80,7 @@ namespace Ark::internal
7980
[[nodiscard]] inline virtual bool withPrefix() const { return false; }
8081
[[nodiscard]] inline virtual bool isGlob() const { return false; }
8182
[[nodiscard]] inline virtual std::string prefix() const { return ""; }
83+
[[nodiscard]] inline virtual bool hasSymbol(const std::string&) const { return false; }
8284

8385
private:
8486
std::unordered_set<Declaration> m_vars {};
@@ -123,6 +125,7 @@ namespace Ark::internal
123125
[[nodiscard]] inline bool withPrefix() const override { return m_with_prefix; }
124126
[[nodiscard]] inline bool isGlob() const override { return m_is_glob; }
125127
[[nodiscard]] inline std::string prefix() const override { return m_namespace; }
128+
[[nodiscard]] inline bool hasSymbol(const std::string& symbol) const override { return std::ranges::find(m_symbols, symbol) != m_symbols.end(); }
126129

127130
private:
128131
std::string m_namespace;

src/arkreactor/Compiler/NameResolution/ScopeResolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace Ark::internal
9898
{
9999
if (top && prefix == scope->prefix())
100100
return std::make_pair(true, maybe_fqn);
101-
if (!top && prefix == scope->prefix() && scope->isGlob())
101+
if (!top && prefix == scope->prefix() && (scope->isGlob() || scope->hasSymbol(name)))
102102
return std::make_pair(true, maybe_fqn);
103103

104104
top = false;

src/arkreactor/Compiler/NameResolution/StaticScope.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <Ark/Compiler/NameResolution/StaticScope.hpp>
22

3-
#include <ranges>
43
#include <utility>
54
#include <fmt/format.h>
65

0 commit comments

Comments
 (0)