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
Now let me check where the existing gate tests live and look at the expr_member gate section fully:
- Assistant
Let me check the parity harness structure and whether node is available:
- Assistant
Now let me implement. First, add the context flag:
- Assistant
Now the call fall-through in expr_call/mod.rs:
- Assistant
Now expr_new.rs fall-through:
- Assistant
Now update the gate itself:
- Assistant
The fixture matches Node exactly. Now verify named-import rejection and call gating still work:
- Assistant
All four distinctions behave correctly. Now run the existing gate tests:
- Assistant
Meanwhile, update CLAUDE.md version line and CHANGELOG:
- Assistant
Writes never routed through this gate before either (assignment lowers
member.objdirectly), so no regression there. Let me check lint on the touched crate: - Assistant
The production diff is complete. Waiting on the workspace test suite:
- Assistant
Those are broad module-inventory tracker entries that auto-flip — leave as-is. Now waiting for the workspace suite:
- Assistant
While that finishes, let me re-verify the final acceptance checks with the rebuilt binary:
- Assistant
The diff is in good shape. Waiting on the workspace test results now.
- Assistant
Working tree is clean apart from the intended changes. The workspace test suite is still compiling in the background — I'll report the final result when it completes.
- Assistant
I'll wait for the background notification rather than polling.
- Assistant
The implementation is complete and all focused tests pass. The full workspace regression suite (thousands of tests across ~40 crates) is compiling in the background; I'll confirm its result when the completion event arrives.
Summary of the fix so far:
crates/perry-hir/src/lower/lowering_context.rs/context.rs— new one-shotmember_callee_of_callflag.crates/perry-hir/src/lower/expr_call/mod.rs— the generic call fall-through marks member-expression callees (peeling TS cast/paren wrappers) before lowering them.crates/perry-hir/src/lower/expr_new.rs— same marking fornew mod.X()member callees.crates/perry-hir/src/lower/expr_member.rs— consumes the flag on entry; the #463 gate now only bails when the member was a call/construct callee. Bare namespace value reads of manifest-absent properties fall through to a plain that evaluates to (Node namespace-miss semantics).
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.