Fix namespace variable export ABI#6315
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughThe compiler replaces namespace re-export tracking with namespace import tracking, broadens variable-shaped namespace dispatch, adjusts object-cache keys, updates compile-option fixtures, and adds integration coverage for cyclic namespace variable exports. ChangesNamespace export ABI
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant ModuleCompiler
participant NamespaceResolver
participant StaticMethodLowering
participant ClosureCallHelpers
ModuleCompiler->>NamespaceResolver: resolve namespace re-export origin
NamespaceResolver->>ModuleCompiler: classify imported variable and store origin mapping
ModuleCompiler->>StaticMethodLowering: lower namespace member call
StaticMethodLowering->>ClosureCallHelpers: retrieve getter closure and invoke with arguments
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/perry-codegen/src/expr/static_method.rs`:
- Around line 265-267: Replace the flat imported_vars check in static-method
handling with a namespace-qualified variable classification keyed by
(class_name, method_name). Populate this set in run_pipeline.rs alongside
namespace_member_prefixes, use it to identify closure-valued namespace exports,
and retain imported_vars for named-import value lowering.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 312e728b-a0d7-4765-97fc-b0b901dadaa3
📒 Files selected for processing (27)
crates/perry-codegen/src/codegen/closure.rscrates/perry-codegen/src/codegen/entry.rscrates/perry-codegen/src/codegen/function.rscrates/perry-codegen/src/codegen/method.rscrates/perry-codegen/src/codegen/mod.rscrates/perry-codegen/src/codegen/opts.rscrates/perry-codegen/src/expr/mod.rscrates/perry-codegen/src/expr/static_method.rscrates/perry-codegen/tests/argless_builtin_extra_args.rscrates/perry-codegen/tests/class_keys_gc_root.rscrates/perry-codegen/tests/constructor_recursion.rscrates/perry-codegen/tests/destructure_call_location.rscrates/perry-codegen/tests/large_object_barriers.rscrates/perry-codegen/tests/macos_bundle_chdir_gate.rscrates/perry-codegen/tests/native_proof_buffer_views.rscrates/perry-codegen/tests/native_proof_regressions.rscrates/perry-codegen/tests/shadow_slot_hygiene.rscrates/perry-codegen/tests/static_symbol_hygiene.rscrates/perry-codegen/tests/typed_feedback.rscrates/perry-codegen/tests/typed_shape_descriptor.rscrates/perry-codegen/tests/typed_shape_descriptors.rscrates/perry/src/commands/compile/object_cache.rscrates/perry/src/commands/compile/run_pipeline.rscrates/perry/tests/namespace_variable_export_abi.rstarget/deepwiki/arraybuffer-dataview-semantics.mdtarget/deepwiki/object-literal-semantics.mdtest-files/issue_321_named_namespace_reexport/main.ts
💤 Files with no reviewable changes (23)
- crates/perry-codegen/tests/static_symbol_hygiene.rs
- crates/perry-codegen/tests/argless_builtin_extra_args.rs
- target/deepwiki/arraybuffer-dataview-semantics.md
- crates/perry-codegen/tests/constructor_recursion.rs
- crates/perry-codegen/tests/typed_shape_descriptors.rs
- crates/perry-codegen/tests/large_object_barriers.rs
- crates/perry-codegen/tests/shadow_slot_hygiene.rs
- crates/perry-codegen/src/codegen/function.rs
- crates/perry-codegen/src/codegen/mod.rs
- crates/perry-codegen/tests/macos_bundle_chdir_gate.rs
- crates/perry-codegen/src/codegen/method.rs
- target/deepwiki/object-literal-semantics.md
- crates/perry-codegen/tests/class_keys_gc_root.rs
- crates/perry-codegen/tests/typed_feedback.rs
- crates/perry-codegen/tests/native_proof_buffer_views.rs
- crates/perry-codegen/tests/native_proof_regressions.rs
- crates/perry-codegen/tests/typed_shape_descriptor.rs
- crates/perry-codegen/src/codegen/entry.rs
- crates/perry/src/commands/compile/object_cache.rs
- crates/perry-codegen/tests/destructure_call_location.rs
- crates/perry-codegen/src/codegen/closure.rs
- crates/perry-codegen/src/expr/mod.rs
- crates/perry-codegen/src/codegen/opts.rs
| // Both wildcard imports and namespaces reached through a | ||
| // re-export use the same getter ABI. | ||
| if ctx.imported_vars.contains(method_name) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Scope variable classification by namespace.
imported_vars is a flat set. If A.make is a declared function and B.make is a closure-valued export, importing both namespaces inserts "make" and makes A.make() call its function body as a zero-arg getter, then invoke its return value as a closure.
Add a namespace-qualified variable set, populated in run_pipeline.rs alongside namespace_member_prefixes, and consult (class_name, method_name) here. Keep the flat set for named-import value lowering.
Proposed direction
- if ctx.imported_vars.contains(method_name) {
+ if ctx
+ .namespace_imported_vars
+ .contains(&(class_name.clone(), method_name.clone()))
+ {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/perry-codegen/src/expr/static_method.rs` around lines 265 - 267,
Replace the flat imported_vars check in static-method handling with a
namespace-qualified variable classification keyed by (class_name, method_name).
Populate this set in run_pipeline.rs alongside namespace_member_prefixes, use it
to identify closure-valued namespace exports, and retain imported_vars for
named-import value lowering.
Summary
js_closure_callNfor every namespace import form.target/deepwikiartifacts.Root cause
Namespace static-member calls treated variable-shaped exports as direct functions unless the namespace came from one specific re-export form. Those exports are getter symbols returning closures, so direct calls returned the closure rather than invoking it.
Validation
cargo fmt --checkCARGO_INCREMENTAL=0 cargo test -p perry --test namespace_variable_export_abi -- --nocaptureCARGO_INCREMENTAL=0 cargo check -p perry -p perry-codegenSummary by CodeRabbit
Bug Fixes
Tests