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:
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:
- Assistant
I’ll trace the member-lowering gate and surrounding native-module handling, reproduce the reported check failure, then implement the narrow distinction between value reads and unsupported calls/imports. I’ll run focused tests/builds and inspect the final diff before submitting.
- Assistant
The relevant code confirms named-import validation is already separate and correctly rejects absent ESM exports. The member gate currently skips only named-import values; namespace imports are represented as
(module, None), so I’ll extend the existing “this is a value imported from the module” exemption to namespace bindings. Calls retain their dedicated native-module gate, preserving rejection of unsupported methods. - Assistant
The patch is intentionally limited to the lowering gate: all import-binding forms (including casts and parenthesized forms already handled by the old exemption) now bypass only the property-read gate. The existing call-form sweep in
unimplemented_api_check.rsstill exercises bogus calls, and its native call lowering performs the strict rejection independently. The repository has no installed Rust toolchain and no release binary, so compilation/tests cannot run here;git diff --checkpasses and the change is syntactically localized.Checklist review:- Reproduced the reported error: not executable in this environment because
target/release/perryis absent and Rust has no installed/default toolchain; source inspection confirmed the exact failing gate. - Confirmed the fix conceptually: namespace bindings are now exempt from the read gate, so runtime
PropertyGetcan returnundefined; named-import validation remains unchanged. - Considered edge cases: casts/parentheses retain the prior handling, named imports remain separately validated, and unsupported calls remain covered by the dedicated call gate.
- Reproduced the reported error: not executable in this environment because
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.