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:
- Assistant
I'll start by reproducing the reported error and inspecting the relevant gate in the HIR lowering code.
- Assistant
I'll examine the member-expression lowering gate and the DNS constants fixture next.
- Assistant
I'll search for the strict API gate around
module_has_symbolandNativeModuleRef. - Assistant
rg is not available, let me use grep.
- Assistant
Let me read the relevant section around line 1722-1850.
- Assistant
Let me continue reading more of this gate logic.
- Assistant
I'll inspect call-site gating and named-import validation next so we can distinguish property misses from real unimplemented APIs.
- Assistant
I'll inspect the call path next to confirm unimplemented methods stay gated separately from property reads.
- Assistant
I'll check for existing tests and comments around this gate's expected behavior.
- Assistant
I'll inspect the unimplemented-API tests and the codegen path for missing native-module properties.
- Assistant
Next I'll inspect runtime PropertyGet handling for native modules and the rest of the tests.
- Assistant
I'll check how the runtime resolves property gets on native module objects.
- Assistant
I'll read the native-module property getter implementation next.
- Assistant
Let me look at get_native_module_constant and what happens for dns constants including CALLLED etc. And also what happens when property is not found.
- Assistant
I'll inspect DNS constant lookup and missing-property fallback behavior next.
- Assistant
I'll check for binary availability and try to reproduce the reported check failure.
- Assistant
No release binary yet — I'll check the workspace layout and start a focused build.
- Assistant
I'll look through recent commits and any docs touching this namespace-read gate.
- Assistant
I'll inspect the API symbol kinds and whether method-only members need special property-read treatment.
- Assistant
I'll check how nested namespaces like
dns.promiseslower when the outer binding is a native module. - Assistant
I'll check the dns-related special cases in member lowering next.
- Assistant
I'll update the member-expression gate so namespace property misses lower normally; calls stay rejected on the call path.
- Assistant
I'll use explicit line-range edits so the replacement is applied cleanly.
- Assistant
I'll use edit 1721:1832 with the new text.
- Assistant
Next I'll verify that handled modules like
fsandcryptostill reject unknown method calls. - Assistant
I'll inspect how
fs.unknown()is handled in call lowering, since fs is a special-cased module. - Assistant
I'll read the early handoff in
lower_call_innerwhere receiver namespaces are handled. - Assistant
I'll inspect
try_module_static_methodsto see how unknown fs/crypto calls[are[ handled. - Assistant
I need to search for how fs methods gates work and Order when native_module skips handled modules.
- Assistant
Let me look at fs method handling around line 152 and how unknown methods fall through.
- Assistant
I'll check the start of try_native_module_methods and how crypto/path calls are structured.
- Assistant
I'll extend the call-site gate so handled modules like
fsandcryptostill reject unknown method renames. - Assistant
I'll navigate to the code region and apply the rewrite there.
- Assistant
Let me try edit with line numbers instead.
- Assistant
I'll clean up the comment typos I introduced.
- Assistant
I'll compile the HIR crate and run the unimplemented-API tests.
- Assistant
Need to configure the Rust toolchain before building.
- Assistant
There's cargo in /usr/local/cargo/bin. rustup has no default. Let me use the full path or set PATH.
- Assistant
Need to find where the actual rustc binary is.
- Assistant
There's toolchain regularly and stable. Let me set default and check rust-toolchain file in repo.
- Assistant
Hmm error without message. Let me try separately.
- Assistant
Toolchain is ready — next I'll compile and run the targeted HIR tests.
- Assistant
I'll fix the path submodule early-return so unknown methods are still gated on call form.
- Assistant
I'll add the unimplemented-call gate before the path submodule dispatch early-return.
- Assistant
I'll confirm path submodule symbols are keyed correctly in the API]") manifest.
- Assistant
I'll write a temporary lowerer script covering the namespace-read, named-import, and call cases.
- Assistant
I'll rewrite that temporary harness as proper unit tests and rerun it.
- Assistant
I'll remove the temporary test file and build the Perry binary so we can run the DNS fixture end-to-end.
- Assistant
Build succeeded. Now run the check and run commands for the fixture.
- Assistant
Check passes. Now I'll run the fixture for runtime output.
- Assistant
I'll locate a newer clang or switch backends so we can execute the fixture.
- Assistant
I'll check available backends and try an alternate codepath for running thinenser the fixture.
- Assistant
I'll look for how perry invokes clang and whether opaque-pointer flags are configurable.
- Assistant
I'll try installing a newer clang so LLVM IR from Perry can compile on this host.
- Assistant
Let me look at linker.rs to add opaque pointers flag temporarily... Actually we shouldn't need to run if check works and HIR is correct. The issue acceptance is:
- Assistant
I'll try compiling the intermediate IR with clang's opaque-pointers option for verification.
- Assistant
Let me try clang -c with -opaque-pointers
- Assistant
I'll fetch a newer portable LLVM toolchain so the fixture can be executed.
- Assistant
Downloading may take a while. Let me try llvm.sh with noninteractive.
- Assistant
lsb_release is missing — I'll check whether the LLVM tarball download finished.
- Assistant
The download is still in progress — I'll wait for it to finish.
- Assistant
Download completed — I'll extract clang-18 and rerun the fixture withrire it.
- Assistant
Need libtinfo.so.5
- Assistant
I'll try bridging libtinfoquir via a compatibility symlink.
- Assistant
I'll pull a Debian libtinfo5 package and install it manually.
- Assistant
Good — next I'll point the dynamic loader at that lib and run the fixture.
- Assistant
I'll verify the named-import probe still fails and that unsupported method calls remain gated.
- Assistant
I'll isolate each probe case so check results don't cross-contaminate.
- Assistant
I'll clean up build artifacts and review the final diff.
- Assistant
I'll update the API-manifest crate docs so they match call-site-only gating.
- Assistant
I'll nudge the related module_export docs to match the call-site distinction.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.