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:
22824ba90abf Expose globalThis.EventTarget (#3628)Node v25.9.0 behavior for the namespace object:
$ 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:
$ 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:
$ target/release/perry check test-parity/node-suite/dns/constants/error-aliases.ts error[U006]: `dns/promises.ADDRCONFIG` is not implemented in Perry — see `perry --print-api-manifest` for the supported surface, or set `PERRY_ALLOW_UNIMPLEMENTED=1` to ignore. (#463) --> test-parity/node-suite/dns/constants/error-aliases.ts:9:48The manifest matches Node for named exports:
dns/promisesincludes DNS error aliases likeNODATAandCANCELLED, but does not includeADDRCONFIG,V4MAPPED, orALL.With the gate bypassed, Perry's runtime output matches Node for this fixture, including the absent namespace properties:
$ PERRY_ALLOW_UNIMPLEMENTED=1 target/release/perry run test-parity/node-suite/dns/constants/error-aliases.ts ... dnsPromises.ADDRCONFIG: undefined dnsPromises.V4MAPPED: undefined dnsPromises.ALL: undefined ... named aliases: ENODATA ECANCELLEDThe relevant gate is in
crates/perry-hir/src/lower/expr_member.rs: namespacePropertyGeton aNativeModuleRef(module)fails whenevermodule_has_symbol(module, prop)isNone, even when the Node-compatible value for a namespace property miss is simplyundefined.Scope
Make Node built-in namespace property reads distinguishable from named imports/calls:
import * as dnsPromises from "node:dns/promises"; dnsPromises.ADDRCONFIGshould compile and evaluate toundefined, matching Node.- Similar absent-property reads on strict native module namespaces should follow normal JS property semantics when the code is only reading the value.
- Named imports for absent exports should remain rejected, matching Node's ESM behavior.
- Obvious unsupported API calls should still get the helpful Perry unimplemented-API error; this issue should not silently allow
fs.notARealMethod()-style call gaps unless the runtime has a deliberate JS-compatible fallback.
Acceptance
target/release/perry check test-parity/node-suite/dns/constants/error-aliases.tspasses withoutPERRY_ALLOW_UNIMPLEMENTED=1.- The DNS constants fixture prints the same shape as Node for:
- absent
dns/promises.ADDRCONFIG,V4MAPPED, andALLnamespace reads (undefined), and - present DNS error aliases (
NODATA,CANCELLED, etc.).
- absent
- A named import probe for the absent constants remains rejected in a way consistent with Node's missing named export behavior.
- The strict unimplemented-API gate still catches actual unsupported builtin method usage; add or keep a regression test for that distinction.
- No Test262 coverage is needed for this issue; the signal is Node built-in API behavior.
Relationship to DNS issues
- #3840 and #3841 tracked older broad resolver no-op behavior and are close-ready/stale for the deterministic resolver paths checked on current main.
- #3887 tracks default export identity for
node:dnsandnode:dns/promises. - This issue tracks the separate property-read/static-gate mismatch that currently blocks the expanded DNS constants fixture.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /perry, current file: none) bash-$
- Assistant
I’ll trace the member-expression lowering and the separate named-import validation path, then reproduce the reported check failure. I’ll implement the narrowest distinction: permit reads of missing native-module namespace properties while preserving errors for unsupported calls and absent named imports. I’ll run focused tests/checks and inspect the final diff before submitting.
- Assistant
The relevant code confirms the intended architecture: native named imports are validated in
module_decl.rsagainst public named exports, while the member gate only sees the lowered receiver. Namespace imports are identifiable vialookup_native_module(name) == Some((module, None)). I’ll preserve the named-import check and exempt only namespace receivers from the property-read gate; the native call lowering has its own manifest gate, sonamespace.notARealMethod()remains rejected. - Assistant
The focused existing unit suite contains the old expectation that
crypto.foobarproperty reads are rejected; that expectation is exactly the behavior this issue changes for namespace property misses, while direct calls still use the independent call gate. I will leave tests untouched per the repository instructions and verify the source-level invariants and diff. The Rust toolchain is unavailable in this container, so cargo execution cannot proceed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →