ISSUE DESCRIPTION Node API checker: namespace reads of absent builtin exports should…
- User
ISSUE DESCRIPTION
Node API checker: namespace reads of absent builtin exports should return undefined
Summary
Perry's strict built-in API gate currently rejects some namespace property reads that Node treats as ordinary JavaScript property misses returning
undefined.This surfaced in the curated DNS constants fixture on current
origin/main@22824ba90abf:node:dns/promisesintentionally does not exportADDRCONFIG,V4MAPPED, orALL, but reading those properties from the namespace object is valid in Node and returnsundefined. Perry rejects the property read at check/lower time before the runtime can produce the matching value.This is separate from named ESM import validation. Node rejects
import { ADDRCONFIG } from "node:dns/promises", and Perry should continue not claiming that named export. The compatibility gap is namespace/property-read semantics.Local evidence
Current main:
text22824ba90abf Expose globalThis.EventTarget (#3628)Node v25.9.0 behavior for the namespace object:
console$ node -e 'import("node:dns/promises").then(m=>{for (const k of ["ADDRCONFIG","V4MAPPED","ALL","NODATA","CANCELLED"]){console.log(k, Object.prototype.hasOwnProperty.call(m,k), k in m, typeof m[k], m[k]);}})' ADDRCONFIG false false undefined undefined V4MAPPED false false undefined undefined ALL false false undefined undefined NODATA true true string ENODATA CANCELLED true true string ECANCELLEDNode rejects the corresponding named import, which is correct and should remain true:
console$ node --input-type=module -e 'import { ADDRCONFIG } from "node:dns/promises"; console.log(ADDRCONFIG)' SyntaxError: The requested module 'node:dns/promises' does not provide an export named 'ADDRCONFIG'Perry currently rejects the namespace property read in the curated fixture:
- Assistant
I'll start by exploring the repository structure and the relevant code around the Node API checker and the mentioned file.
- Assistant
I'll inspect the member-expression lowering and the DNS constants fixture next.
- Assistant
I'll search for the namespace PropertyGet gate and related module-symbol checks.
- Assistant
rg is not available, let me use grep.
- Assistant
The key section is around line 1722-1837. Let me read that area.
- Assistant
Let me continue reading the gate logic.
- Assistant
I'll inspect how call sites gate unimplemented APIs and how similar cases are tested.
- Assistant
I'll check how member access and call sites interact when something like
mod.method()is lowered. - Assistant
There's a comment about the member and call gates interacting — I'll read that next.
- Assistant
I'll verify what PropertyGet does at runtime for missing native-module symbols, and look for related tests.
- Assistant
There are relevant tests and runtime helpers — I'll read those next.
- Assistant
I'll look for recent related changes and how typeof treats missing members.
- Assistant
There's already a comment on this exact subject in the node_submodules code — I'll read it.
- Assistant
I'll check whether a release binary exists, then try to reproduce the reported failure.
- Assistant
No prebuilt binary — I'll try running the relevant HIR unit tests after a focused build.
- Assistant
Looking at dns/promises - it has methods and error codes but not ADDRCONFIG. Let me see the error aliases:
- Assistant
Hmm, I need to see dns/promises properties for NODATA etc.
- Assistant
Interesting - dns/promises doesn't seem to have NODATA etc as properties in the first block. Let me search more carefully - maybe they're elsewhere or maybe the fixture was expanded recently.
- Assistant
Checking named-import rejection and how module names normalize.
- Assistant
Named imports are already rejected separately. Good.
- Assistant
Implementing the fix: allow missing namespace property reads to lower to PropertyGet (undefined at runtime), while keeping the call-site gate.
- Assistant
Looking at this more carefully - should I completely remove the gate or change its behavior?
- Assistant
Checking how specialized handlers treat unknown method calls for fs/crypto/os/path.
- Assistant
I'll verify what happens when a bogus method call falls through for handled modules like
fs. - Assistant
Checking the dns.promises namespace path and whether handled modules need call-site gating extended.
- Assistant
I'll update the property-read gate and extend call-site gating to handled modules so method calls still error.
- Assistant
The counter edit landed in the wrong file — I'll revert that and apply the change to
expr_member.rs. - Assistant
mod.rs looks correct after checkout. expr_member is unscathed. Let me properly editexpr_member.rs.
- Assistant
I'll replace the gate block with a comment and drop the entire if block.
- Assistant
There's a leftover brace from the old if-block — removing it.
- Assistant
Updating the call gate so handled modules still reject unknown methods.
- Assistant
I'll replace the whole block from is_handled_module through the end of the if.
- Assistant
Checking nested namespace call fallthrough for unknown methods like
dns.promises.notReal(). - Assistant
Checking how unknown
processmethods are handled and whether they employ the transparent gate. - Assistant
Looking at process match - does it have a
_ => {}? - Assistant
I need the section that resolves import aliases to module names.
- Assistant
Confirming that early os/fs handlers fall through properly for unknown methods.
- Assistant
I'll build and run the relevant HIR unit tests, plus a temporary repro for the DNS case.
- Assistant
Need to set up rustup.
- Assistant
Rust is ready — building and running the related tests next.
- Assistant
path/posixandpath/win32bypass the gate via early return — I'll inspect that path next. - Assistant
I need to gate path submodule unknown methods. Looking at dispatch_path_subnamespace - when method is unknown it returns Err(args). I should add a gate before that return, or after dispatch returns Er...
- Assistant
I'll gate unknown methods on the path submodule early-return path.
- Assistant
Also check try_path_subnamespace for path.posix.bogus() form - 3 deep.
- Assistant
Re-running the call-form tests and adding a temporary DNS property-read check.
- Assistant
All probes pass. Cleaningвзрослы temp files and verifying the full DNS fixture lowers.
- Assistant
The DNS fixture lowers cleanly. Cleaning temp files and verifying end-to-end runtime behavior if a full build is practical.
- Assistant
As expected, only property-read form tests fail. Building
perryand running the fixture end-to-end. - Assistant
Good, perry builtን. Let's run check on the fixture.
- Assistant
Check passed for the DNS fixture. Validating runtime undefined notes next.
- Assistant
LLVM/clang is mismatched in this environment; the check path is what matters. Verifying the final diff is clean.
- Assistant
Let me also verify that the dns_promises CODEGEN returns undefined for ADDRCONFIG - to give confidence on runtime with PERRY. The issue already verified that with ALLOW_UNIMPLEMENTED.
- Assistant
Let me verify native_module property sitsundefined for dns/promises ADDRCONFIG via a quick C ABI cal ifpossible, вре or just trust existing issue empirical evidence.
- Assistant
Checking dns/promises property dispatch to confirm ADDRCONFIG resolves to undefined.
- Assistant
Confirmed: ADDRCONFIG is not a dns/promises alias, so it correctly yields undefined. Doing a final status check, then submitting.
- Assistant
perry check only takes one input. Let me run individually.
- Assistant
The checker seems to be aggregating earlier files — I'll isolate each case.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.