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 inspect the lowering paths and existing API-gate tests, then make the narrow read-vs-call distinction and run targeted checks.
- Assistant
rgisn’t installed here, so I’m using focusedgrep/sedsearches. The key question is whether the caller context is already tracked during member lowering or needs a small lowering-context flag. - Assistant
The architecture already has the needed separation: direct module calls have their own manifest gate, and named imports are validated in import lowering. I’m removing only the namespace value-read refusal and updating the regression suite so unknown reads compile while unknown calls and missing named imports still fail.
- Assistant
The focused test target is building now. After it passes, I’ll run the release checker and fixture itself to verify both compile-time behavior and the emitted
undefinedvalues. - Assistant
The first test run exposed an important dependency: seven specially dispatched modules (
fs,path,crypto, etc.) relied on the old property-read gate even for calls. I’m moving the strict unknown-method check into the common call path so all calls remain protected, then removing one obsolete read-rejection test. - Assistant
The HIR regression suite now passes all 14 cases, including a full native-module sweep for both allowed reads and rejected calls. The release build is in progress so I can validate the exact CLI acceptance commands against the rebuilt binary.
- Assistant
The release build has reached the final Perry binary link; no compilation errors have appeared. Once it completes, the remaining checks are the DNS fixture, a missing named import probe, and an unsupported
fscall probe. - Assistant
The exact release
checknow passes. Running the fixture is blocked by the workspace toolchain: Perry emits opaque-pointer LLVM IR, while the installed Clang 14 rejects it before linking. I’m checking whether an installed newer Clang or alternate local backend can complete the runtime verification. - Assistant
Both CLI negative probes still fail with the intended diagnostics: missing DNS named export and unsupported
fs.notARealMethod(). I found a possible local workaround for Clang 14’s opaque-pointer mode and am trying it so the fixture can run end to end rather than stopping at the environment limitation.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.