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 member-lowering and import-validation paths, then adjust only namespace value reads and add focused regressions for reads, named imports, and unsupported calls.
- Assistant
rgisn’t installed in this checkout, so I’m usingfind/grepfor the same repository inspection. - Assistant
The direct-call path already performs its own manifest check, while named imports are validated separately in module declaration lowering. I’m removing the manifest refusal only from plain namespace member reads and updating the old tests that intentionally enforced the now-incorrect read behavior.
- Assistant
The focused Rust tests are building now. Formatting tooling is absent in the installed toolchain, but the patch passes whitespace checks; I’ll verify style manually and continue with the release-binary fixture once tests finish.
- Assistant
The regression sweep exposed seven specially dispatched built-ins (
fs,path,crypto,os, and related namespaces) whose calls had relied on the read gate. I’m adding one call-context gate before specialized dispatch so all direct namespace calls remain consistently rejected. - Assistant
The focused regressions now pass, including a sweep across every supported native module for both allowed property misses and rejected bogus calls. The release build is in its final compile/link stage before running the DNS fixture end to end.
- Assistant
The required
perry checknow passes. The runtime fixture reached code generation but the host’s default Clang 14 cannot parse Perry’s opaque-pointer LLVM IR; I’m checking for a compatible installed compiler/backend so runtime output can still be verified locally.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.