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 inspect the repository and the member-lowering/API-gate implementation first, then reproduce the reported check failure, trace how namespace reads differ from calls/imports, implement the narrowest fix, and run focused tests plus the relevant fixture.
- Assistant
The gate is concentrated near the end of
lower_member_inner; I’ll inspect that block and the call-lowering path to ensure an absent property becomesundefinedonly for value reads, while(...)still reaches the unimplemented API diagnostic. I’ll also inspect existing tests and fixture commands. - Assistant
The existing call path independently checks
module.method(...), so the safe design is to relax only the property-read gate for namespace bindings (lookup_native_modulereturnsSome((module, None))), leaving named imports and direct call validation intact. I’ll verify the fixture/import lowering and existing regression tests before editing. - Assistant
The fixture uses namespace imports exactly as expected, and generic
PropertyGetalready yields the runtime’sundefinedfor missing native-module members. I’ll add a namespace-binding classification alongside the existing named-import classification and exclude only namespace value reads from this gate; the dedicated call lowering remains unchanged and continues rejecting unsupported calls. - Assistant
The source change is in place, but Cargo cannot run because this environment has no configured Rust toolchain. I’ll verify the diff, use the existing Perry binary if available for the reported end-to-end checks, and inspect project scripts/toolchain configuration for any runnable alternative.
- Assistant
The diff is syntactically localized and passes
git diff --check. Computed namespace accesses already bypass this identifier-only manifest gate (while dynamic namespace dispatch remains protected by the separate security guard), and named-import validation is untouched. Since no Rust toolchain or built binary exists, I’ll perform final source-level checks and review the exact diff before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.