Node API checker: namespace reads of absent builtin exports should return undefined…
- User
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:
console - Assistant
I’ll trace the lowering paths for member reads, calls, and named imports, then patch the narrow distinction and run the relevant Rust and parity tests.
- Assistant
rgisn’t installed in this checkout, so I’m using targetedfind/grepsearches. I’m first checking repository guidance and the exact HIR lowering code before editing. - Assistant
The code confirms the right seam: bare namespace reads are rejected in
lower_member, while direct namespace calls have an independent manifest gate inlower_call. I’ll remove only the read-time refusal, preserve the call gate, and update regressions to assert missing reads compile, missing calls fail, and missing named imports fail. - Assistant
The regression suite is compiling from a cold cache. The implementation now lets missing namespace values reach the existing runtime property lookup; the separate direct-call test sweep remains unchanged and will verify the diagnostic gate still fires.
- Assistant
The first test run exposed an important coupling: seven specially lowered core modules (
fs,path,crypto,os, and related namespaces) had relied on the member-read gate even for calls. I’m moving the strict unknown-symbol check to the common native-call entry so every directmodule.missing()form remains rejected, including those special dispatch paths. - Assistant
The focused HIR suite now passes all 13 tests, including the full native-module call sweep. Next I’m validating the requested release CLI check and runtime output for the DNS fixture itself.
- Assistant
There isn’t a prebuilt release binary in this workspace, so I’m building it locally before running the exact acceptance command.
- Assistant
The release build is still linking after compiling the workspace dependencies; no errors have appeared, only existing warnings.
- Assistant
The release linker is taking longer than the compile but remains active. I’m letting it finish so the verification uses the exact optimized binary requested in the acceptance criteria.
- Assistant
The exact release
checknow passes. Runtime compilation reached code generation but the host’s default Clang 14 cannot parse the opaque-pointer LLVM IR; I’m checking for a newer installed Clang to complete the output verification without changing the repository. - Assistant
All
perry-hirtests pass (236 executed across unit/integration suites, 2 pre-existing ignored), and the release acceptance check passes. The only uncompleted runtime execution is environmental: installed Clang 14 rejects the project’s opaque-pointer IR before linking. The lowering/runtime path itself is covered by the fixture check and focused regressions.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.