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 lowering logic, related diagnostics/tests, and repository status first. Then I’ll reproduce the reported check failure, make the smallest context-sensitive change that permits reads while preserving call and named-import validation, and run focused tests.
- Assistant
The file is large and
ripgrepis unavailable, so I’ll usegrepto locate the exact strict-gate branch and call-lowering counterpart, plus tests that assert the U006 behavior. - Assistant
I found separate gates: member lowering rejects every missing property, while call lowering independently rejects missing methods. I’ll inspect both branches and import lowering to verify that removing/narrowing only the read gate cannot accidentally admit named imports or calls.
- Assistant
The call path has its own manifest rejection before dispatch, so allowing
PropertyGetwill not allowfs.notARealMethod(). The runtime/codegen already returns the desired missing value according to the report. Before editing, I’ll reproduce with the available binary and inspect import registration/validation to ensure absent named imports remain independently rejected. - Assistant
Named-import validation is explicitly in
module_decl.rsviamodule_has_public_named_export, independent of member reads. There is already a focusedunimplemented_api_checkintegration test suite; I’ll inspect it to understand current expectations and identify whether the repository already contains the requested distinction tests. - Assistant
The existing suite reflects the old policy and contains both obsolete read-rejection assertions and the still-required call-rejection sweep. Per the issue, all namespace value reads should use JavaScript miss semantics, not just DNS names, so the correct source change is to remove the member-read manifest gate entirely while retaining direct-call gates. I’ll update the lowering comments and manifest documentation accordingly; I will not modify tests as instructed.
- Assistant
The source change is complete and formatting-clean. To verify behavior without adding/modifying tests, I’ll first compile and run focused existing tests for (1) missing named-import rejection and (2) unsupported direct-call rejection. Then I’ll use the CLI against the DNS fixture for the positive read case.
- Assistant
The test attempt is blocked because rustup has no selected default toolchain. I’ll inspect the repository’s pinned toolchain/config and installed toolchains, then select the appropriate installed version rather than changing project files.
- Assistant
No Rust toolchain is installed and the repository does not pin one. I’ll install the minimal stable toolchain so the focused verification can run; this only changes the environment, not repository files.
- Assistant
The toolchain itself installed successfully, but the rustup proxy is misconfigured after selection (
cargoproxy looks under/root/.cargo). I’ll invoke the installed binaries directly and rerun the focused tests. - Assistant
The named-import test passed, but the call sweep exposed an important edge case: seven specially dispatched modules (
fs,path,crypto, etc.) historically relied on the removed read gate even for direct calls because their call branch skips the generic call gate. I’ll move/add the manifest call validation immediately after recognizing a namespace call, before special-module dispatch, and remove the duplicate generic-only check. This preserves the requested strict distinction for every module. - Assistant
The early return for
path/posixconfirms validation must occur at the very start of the recognized native-module call branch. I’ll insert it there for identifier methods, then leave the later manifest-kind check in place while removing only its now-redundant missing-symbol diagnostic block. - Assistant
The extracted duplicate block also contained the
manifest_entrybinding needed for the later callable-kind check. I’ll restore that local lookup, then compile and rerun the call sweep; formatting appears already rustfmt-compatible, but I’ll install rustfmt afterward for an authoritative check. - Assistant
The full unsupported-call sweep now passes, including
fs,crypto, and path variants. For the exact positive case, I’ll run a temporary (then deleted)perry-hirexample that parses and lowers the curated DNS fixture—the same stage that previously emitted U006. I’ll also probe an absent named import through the same harness to directly verify rejection. - Assistant
The exact DNS fixture now lowers successfully without the bypass, while the absent
ADDRCONFIGnamed import fails with the expected missing-export message. I’ll perform final formatting, run the manifest unit suite and representative supported-call test, then inspect the final diff/status for accidental files. - Assistant
Final status contains only the three intended source files, formatting passes, and focused tests are green. To satisfy the reproduction checklist precisely despite the initially missing binary, I’ll temporarily compile the original
expr_member.rsthrough the same disposable lowering probe, confirm the fixture emits the reported U006-class error, and immediately restore the fixed file; no test or probe file will remain.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.