Skip to content

Commit

Permalink
feat(name resolution): allow fqn if the scope is only exporting symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFola committed Dec 4, 2024
1 parent c424993 commit feae266
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/Ark/Compiler/NameResolution/StaticScope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace Ark::internal
[[nodiscard]] inline virtual bool withPrefix() const { return false; }
[[nodiscard]] inline virtual bool isGlob() const { return false; }
[[nodiscard]] inline virtual std::string prefix() const { return ""; }
[[nodiscard]] inline virtual bool hasSymbol(const std::string&) const { return false; }

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

private:
std::string m_namespace;
Expand Down
2 changes: 1 addition & 1 deletion src/arkreactor/Compiler/NameResolution/ScopeResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace Ark::internal
{
if (top && prefix == scope->prefix())
return std::make_pair(true, maybe_fqn);
if (!top && prefix == scope->prefix() && scope->isGlob())
if (!top && prefix == scope->prefix() && (scope->isGlob() || scope->hasSymbol(name)))
return std::make_pair(true, maybe_fqn);

top = false;
Expand Down

0 comments on commit feae266

Please sign in to comment.