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:
22824ba90abf Expose globalThis.EventTarget (#3628)Node v25.9.0 behavior for the namespace object:
$ 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:
$ 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:
$ target/release/perry check test-parity/node-suite/dns/constants/error-aliases.ts error[U006]: `dns/promises.ADDRCONFIG` is not implemented in Perry — see `perry --print-api-manifest` for the supported surface, or set `PERRY_ALLOW_UNIMPLEMENTED=1` to ignore. (#463) --> test-parity/node-suite/dns/constants/error-aliases.ts:9:48The manifest matches Node for named exports:
dns/promisesincludes DNS error aliases likeNODATAandCANCELLED, but does not includeADDRCONFIG,V4MAPPED, orALL.With the gate bypassed, Perry's runtime output matches Node for this fixture, including the absent namespace properties:
- Assistant
I'll start by exploring the repository structure and reproducing the issue with the DNS constants fixture.
- Assistant
I'll inspect the member expression lowering and the DNS constants fixture next.
- Assistant
Let me search for module_has_symbol and NativeModuleRef related code in expr_member.rs
- Assistant
rg not found, use grep instead
- Assistant
Found the relevant code around line 1741. Let me read that section.
- Assistant
Let me continue reading the gate code
- Assistant
I need to understand how call sites and named-import validation interact with this gate.
- Assistant
I'll inspect the call-path gate and named-import validation next.
- Assistant
I'll check Node's behavior for missing properties versus missing method calls, and look for related tests.
- Assistant
There's relevant runtime notes about namespace property miss semantics; I'll inspect those.
- Assistant
I'll check the DNS manifest entries and any prior related comments or issues.
- Assistant
There's an unimplemented_api_check test — I'll open it.
- Assistant
Let me see the rest of the test file and whether dns/promises has NODATA etc.
- Assistant
I'll check DNS promises property entries and the rest of the unimplemented-api tests.
- Assistant
I'll inspect how call lowering treats member callees and whether it goes through the member tonnage path.
- Assistant
I need to understand default/namespace vs named import bindings and how that interacts with property-read gating.
- Assistant
I'll look for prior discussion of this issue and any nearby related fixes.
- Assistant
I'll reproduce the failure first, then implement the property-read gate change.
- Assistant
Need to set up rustup
- Assistant
I'll check for an existing binary and start a targeted build.
- Assistant
I'll update the member-property unimplemented gate so bare namespace reads fall through to undefined while call sites stay gated.
- Assistant
I'll check how handled modules like crypto gate unknown method calls.
- Assistant
I need to find every place that emits the unimplemented-API call gate.
- Assistant
I'll read native_module method trying more carefully to see how handled modules reject bogus calles.
- Assistant
I'll inspect LoweringContext fields for an existing call-callee flag.
- Assistant
There's
namespace_importDebian locals. Let me find the LoweringContext struct definition. - Assistant
I'll inspect crypto/os/path special-casing and fallthrough in try_native_module_methods.
- Assistant
I'll find out where crypto/fs/path dotted facilities call sites are lowered.
- Assistant
I'll check expr_new and other paths that lower members used as call/construct callees.
- Assistant
I'll check how public named exports interact with property-only entries.
- Assistant
I'll check how entry_is_public_named_export treats Property entries.
- Assistant
I'll inspect expr_new around the fallthrough and NativeModuleRef handling.
- Assistant
I'll check how default imports register native modules for non-Node packages.
- Assistant
There's а subtlety: for named imports of classes like
import { EventEmitter } from "events"; EventEmitter.on- the object is behaved as NativeModuleRef without... wait lookup returns (module, Some("E... - Assistant
I'll remove the property-read gate and float the call-form gate so it covers handled modules too.
- Assistant
I'll apply both code changes now.
- Assistant
There's a corrupted line with a control character — I'll fix it.
- Assistant
Wait — I need to verify theDISPATCH order of try_native vs try_module_static.
- Assistant
I'll update1 the property-read gate in expr_member.rs next.
- Assistant
Need to navigate to the right location first.
- Assistant
I'll use a Python script for a more reliable multi-line replacement.
- Assistant
I'll verify both edits and check for issues around the changed sections.
- Assistant
I'll build perry-hir and run the unimplemented-API tests next.
- Assistant
path/posix and path/win32 skip the call gate; I'll inspect and fix that path.
- Assistant
I'll add the call-form gate to the path submodule dispatch branch.
- Assistant
Need to goto line first
- Assistant
Now replace
- Assistant
I'll re-run the call-form tests and write a temporary script to validate the DNS namespace behavior.
- Assistant
filter is one pattern
- Assistant
I'll write a temporary verification script, then build perry for end-to-end checks.
- Assistant
Removing the temporary test and building release perry for the fixture check.
- Assistant
Build succeeded; I'll run check and run on the DNS constants fixture.
- Assistant
perry checkfor the fixture passed. I'll isolate the remaining probes and see if run can work. - Assistant
I'll isolate the probes in separate directories so check only sees one file each.
- Assistant
There's a clang IR version mismatch on run; I'll try a newer clang.
- Assistant
I'll verify the final diff and run a few more related tests.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.