Commit c086f27
Ralph Küpper
fix(hir): aliased native-class import
An aliased ESM named import of a Node built-in class (`import { BlockList
as Wj4 } from "net"; new Wj4()`, `{ AsyncLocalStorage as J_z } from
"async_hooks"`, `{ PassThrough as Lrz } from "stream"`) threw
`ReferenceError: identifier is not defined` when constructed at module
init, crashing the natively-compiled Claude Code cli.js 2.1.112 bundle on
nearly every command.
The alias-rewrite block in `lower_new` (#5472) already rewrites the
callee `class_name` from the local import name (`Wj4`) to the class's
EXPORT name (`BlockList`) so construction matches the un-aliased form.
The unresolved-`new` guard added in #8688 then re-probed
`lookup_native_module(&class_name)` under that rewritten export name, but
the registry is keyed on the LOCAL import name, so the lookup missed;
none of these classes are reified global builtins, so the guard fired and
threw even though the binding is perfectly resolvable. The guard now also
consults the registry under the original imported identifier, so aliased
native-class imports resolve and construct exactly like their un-aliased
form. Un-aliased imports and genuinely-undefined `new` targets are
unchanged.
Fixes #8730
Claude-Session: https://claude.ai/code/session_01TwxRkALrR9HKSF1zKLSTAFnew no longer throws ReferenceError1 parent d53f34b commit c086f27
3 files changed
Lines changed: 116 additions & 0 deletions
File tree
- changelog.d
- crates/perry-hir
- src/lower
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1571 | 1571 | | |
1572 | 1572 | | |
1573 | 1573 | | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
1574 | 1587 | | |
1575 | 1588 | | |
1576 | 1589 | | |
1577 | 1590 | | |
1578 | 1591 | | |
1579 | 1592 | | |
| 1593 | + | |
1580 | 1594 | | |
1581 | 1595 | | |
1582 | 1596 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
0 commit comments