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 the relevant code mentioned in the issue to understand how namespace property reads are gated.
- Assistant
Let me examine the member expression lowering and the DNS constants fixture.
- Assistant
I'll search for the namespace property-get gate and related symbols next.
- Assistant
Reading the gate logic around NativeModuleRef property access.
- Assistant
Let me continue reading the gate logic.
- Assistant
I'll examine how call sites gate unimplemented APIs and whether related handling already exists.
- Assistant
Checking whether call lowering still catches unimplemented methods after a bare property-get is allowed.
- Assistant
Checking the API manifest for DNS entries and whether it distinguishes Node-present vs Perry-absent APIs.
- Assistant
I'll check for an existing binary and any related tests or prior discussions of this behavior.
- Assistant
Looking for tests and comments describing desired namespace-read behavior.
- Assistant
Reading the unimplemented API check tests to understand the expected behavior.
- Assistant
Let me read more of this file especially around property reads vs calls.
- Assistant
Checking how named imports of missing symbols are rejected.
- Assistant
Checking how Node builtins are distinguished from other native modules.
- Assistant
Inspecting named-export validation and builtin module helpers:
- Assistant
Searching for a Node export inventory separate from Perry's implementaton list.
- Assistant
Checking how the API manifest distinguishes public named exports vs implemented symbols.
- Assistant
Verifying whether call lowering lowerMembers through the gate or handles AST directly.
- Assistant
Checking whether
new module.Something()is gated separately. - Assistant
Let me look at that section of expr_new.rs
- Assistant
Looking for NativeModule constructor handling earlier in expr_new.
- Assistant
I'll look at typeof handling for NativeModuleRef properties.
- Assistant
Checking codegen typeof handling for missing native-module properties.
- Assistant
Checking how
dns.promisesand related nested namespace reads are handled. - Assistant
Checking whether
dns.promisesis registered. - Assistant
Checking how nested properties like
dns.promises.Xare lowered. - Assistant
Implementing the fix: allow Node core namespace property misses while keeping call-site and non-Node gates.
- Assistant
I'll regenerate the target section from the exact file contents before applying the patch.
- Assistant
I'll make a minimal edit to the gate condition and comments using a precise patch.
- Assistant
Verifying the edit and whether computed property access needs the same treatment.
- Assistant
Building Perry and verifying the fixture checks and runs successfully.
- Assistant
Need to set up rust toolchain.
- Assistant
Now build again. This might take a while.
- Assistant
Build finished; checking the DNS fixture and related regressions next.
- Assistant
Telemetry prompt is blocking non-interactive runs — I'll disable it.
- Assistant
I'll set PERRY_NO_TELEMETRY=1 or CI=true
- Assistant
Check passed. Running the fixture and named-import / call-gate regressions next.
- Assistant
Resolving the LLVM/clang version mismatch so we can run the fixture.
- Assistant
I'll look up how to select the compile backend and whether a newer clang is available.
- Assistant
Installing a newer clang so we can run the fixture end-to-end.
- Assistant
Try clang-16 or download llvm
- Assistant
clang-19 is available.
- Assistant
Running relevant HIR tests to confirm call-site gating and axios still behave as expected.
- Assistant
Investigating modules whose call gate is skipped by specialized handling.
- Assistant
Tracing fall-through for handled-module calls after specialized arms miss.
- Assistant
The call-site gate currently skips handled modules like
fs/path/cryptobecause member lowering rejected them earlier. I'll extend that gate so unknownmethods on those modules still error. - Assistant
Restructuring the call-site gate so it always runs for native-module method calls, including handled modules.
- Assistant
I'll patch by specific line ranges instead.
- Assistant
There are special unicode characters (em dash) which may have caused the match tofail. I'll replace by line indices.
- Assistant
Rebuilding and re-running the targeted tests.
- Assistant
path/posix and path/win32 still miss the call gate — inspecting submodule dispatch.
- Assistant
Looking at the early-return for path submodules — when dispatch fails it skips the call gate.
- Assistant
Updating path submodule handling so unknown methods fall through to the call gate.
- Assistant
Retesting the call/path submodule path.
- Assistant
argsis passed by value on success but returned on error — I'll keep the original binding on failure. - Assistant
I'll change
argstomut argsin the function signature. - Assistant
Retest.
- Assistant
Call-site gating is restored. Reconfirming the fixture and acceptance probes.
- Assistant
I'll quickly verify the util.types unimplemented-path test still passes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.