Skip to content

module style 2: Isolate the module resolver and start being able to test it independently of module style, which requires more changes - #327

Merged
prozacchiwawa merged 46 commits into
mainfrom
20260122-start-resolve
Apr 15, 2026
Merged

prozacchiwawa merged 46 commits into
mainfrom
20260122-start-resolve

Conversation

@prozacchiwawa

@prozacchiwawa prozacchiwawa commented Jan 23, 2026 •

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Introduces new namespace/import parsing and a new resolution pass that rewrites helper references, which can change name binding and helper selection during compilation. Risk is moderate because it touches frontend parsing/tree-shaking and adds substantial new resolution logic with new error paths.

Overview
Adds module-style plumbing by introducing new HelperForm variants for (namespace ...) and (import ...), plus supporting types to parse dotted ImportLongNames and import specs (qualified, exposing, hiding, and as renames).

Implements a new compiler::resolve pass (resolve_namespaces) that walks expressions/helpers, resolves referenced helpers through active imports, rewrites calls to fully-qualified names, and pulls in the required helper definitions; classic defmacro usage is rejected in this module-style resolver path.

Updates the frontend to parse namespace/import, be more tolerant via helper-head atomize(), and to keep namespace declarations during live-helper filtering; updates rename logic to handle namespace containers; exports codegen and makes do_desugar/is_at_capture public; adds targeted resolver tests under src/tests/compiler/resolve.rs.

Reviewed by Cursor Bugbot for commit d3f062c. Bugbot is set up for automated code reviews on this repo. Configure here.

@prozacchiwawa
prozacchiwawa changed the base branch from main to 20260121-compile-context January 23, 2026 19:04
@prozacchiwawa prozacchiwawa changed the title Isolate the module resolver and start being able to test it independently of module style, which requires more changes module style 2: Isolate the module resolver and start being able to test it independently of module style, which requires more changes Feb 13, 2026
@prozacchiwawa
prozacchiwawa marked this pull request as ready for review February 17, 2026 10:09
Comment thread src/compiler/resolve.rs
Comment thread src/compiler/comptypes.rs
…g imports so the reader is aware they're not supposed to apply to the header part. Break out keyword type earlier so we can forbid 'as' in hiding, (not strictly necessary, but 'as' never does anything more for hiding. Add an additional 'as' test.
Comment thread src/compiler/frontend.rs
Comment thread src/compiler/resolve.rs
…he name location for the full defnsref result in frontend, simplifying things. Reassign the bindings in order when rebuilding a namespace resolved assign form in the module resolver, for consistency even though these should always be considered in topologically sorted order.
Comment thread src/compiler/comptypes.rs Outdated
Comment thread src/compiler/comptypes.rs Outdated
Comment thread src/compiler/resolve.rs Outdated
…py+paste error from when the code was structured a bit differently.
…veloped and relates to phantom helpers created by type definitions. It isn't needed yet and should be improved when it is.
Comment thread src/compiler/comptypes.rs Outdated
Comment thread src/compiler/comptypes.rs
Comment thread src/compiler/resolve.rs
Comment thread src/compiler/comptypes.rs
Comment thread src/compiler/comptypes.rs Outdated
Comment thread src/compiler/resolve.rs Outdated
Base automatically changed from 20260121-compile-context to main March 10, 2026 21:51

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Qualified name lookup skips parent namespace check
    • Added a parent-namespace compatibility guard in the direct helper-match loop so qualified names no longer resolve to unrelated local helpers.

Create PR

Or push these changes by commenting:

@cursor push eb283ac921
Preview (eb283ac921)
diff --git a/src/compiler/resolve.rs b/src/compiler/resolve.rs
--- a/src/compiler/resolve.rs
+++ b/src/compiler/resolve.rs
@@ -170,7 +170,8 @@
     // check the matching namespace to the one specified to see if we can find the
     // target.
     for h in home_ns.iter() {
-        if h.helper.name() == &child
+        if (parent.is_none() || parent.as_ref() == parent_ns)
+            && h.helper.name() == &child
             && !matches!(
                 h.helper,
                 HelperForm::Defnsref(_) | HelperForm::Defnamespace(_)

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread src/compiler/resolve.rs
@prozacchiwawa
prozacchiwawa merged commit 73eefad into main Apr 15, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants