-
-
Notifications
You must be signed in to change notification settings - Fork 161
fix(hir): resolve native-instance chain detection by import provenance, not spelling #10699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+391
−26
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| **A `perry.compilePackages` copy of commander, lru-cache, or decimal.js is no | ||
| longer overridden by their bundled native bindings.** `new Command()`, | ||
| `new LRUCache()`, and `new Decimal()` chained directly onto a method call | ||
| (`new Command().name(...)`, `new LRUCache(...).set(...)`, | ||
| `new Decimal(...).dividedBy(...)`) matched those class names unconditionally | ||
| and routed straight to the native handle, even when the user asked for the | ||
| real package to be compiled from source — the only way to opt out was to | ||
| rename the import. Construction and method dispatch now resolve through the | ||
| same compilePackages-aware provenance table `is_native_module` already | ||
| consults, so a compiled copy of the real package runs its own code at its | ||
| documented import name. The (unmodified) native binding still installs when | ||
| the package is not opted into `compilePackages`. Fixes #10439. | ||
|
|
||
| `crates/perry-hir/tests/fluent_chain_lowering.rs`'s | ||
| `native_fluent_chain_still_dispatches_through_native_methods` asserted the | ||
| pre-fix, ambient/no-import, spelling-based dispatch this change deliberately | ||
| tightens (a bare `new Decimal(1)` with no import now correctly falls through | ||
| to an unresolved-global reference, matching Node's `ReferenceError`, instead | ||
| of silently reaching the native handle). That test predates this change and | ||
| was never updated for it, so it went red on this same commit without this | ||
| diff touching its file — caught by the sweep's `cargo test --workspace`, | ||
| not by any diff-scoped gate. Removed here, with the rationale recorded | ||
| inline, rather than left for a descendant PR to patch around a third time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50370
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 15192
Guard native-instance detection at unhandled binding sites.
detect_native_instance_exprrecursively reachesnew Decimal(...)innew Decimal(...).dividedBy(...)and performs a name-only lookup. ADecimalparameter in the arrow, function-expression, or object-method lowering paths, and a destructuredDecimallocal, do not register a module shadow. IfDecimalis registered for the enclosing module,lookup_native_modulecan therefore classify the non-native binding asdecimal.js. Addshadow_native_module_if_presentat those binding sites. Keep the existing guard for simple locals and the parameter paths that already call it.🤖 Prompt for AI Agents