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 f178f65
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/Ark/Compiler/NameResolution/StaticScope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <optional>
#include <memory>
#include <vector>
#include <ranges>
#include <unordered_set>

namespace Ark::internal
Expand Down Expand Up @@ -79,6 +80,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 +125,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
1 change: 0 additions & 1 deletion src/arkreactor/Compiler/NameResolution/StaticScope.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <Ark/Compiler/NameResolution/StaticScope.hpp>

#include <ranges>
#include <utility>
#include <fmt/format.h>

Expand Down

0 comments on commit f178f65

Please sign in to comment.