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
Good, named import validation is separate. Now let's find the LoweringContext struct to add a flag, and see how
lower_call_inner's fallback works precisely.Assistant
Good, that's separate and already fine. Now let's look at the LoweringContext struct definition to see existing similar flags (like
suppress_stdlib_dispatch_guard_once).Assistant
Now let's add a
KNOWN_ABSENT_PROPERTIESlist plus lookup function. First check the entries.rs file structure near the end for a good place to add the list, and check imports.Assistant
Let's check the tail of entries.rs to find a good place to append the new list.
Assistant
Now let's append the new const array to entries.rs, and add the lookup + doc export.
Assistant
Now update lib.rs export line:
Assistant
Good. Now let's update
expr_member.rsgate to consult this new function.Assistant
Now let's edit lines 1810-1814.
Assistant
Now let's build the workspace and run the relevant tests.
Assistant
No pinned toolchain file. Let's build.
Assistant
Build succeeded. Now let's run the check command from the issue.
Assistant
The check passes now. Let's also run it and compile/run to check output matches Node semantics.
Assistant
That works. Let's update the wrapper script accordingly and retry.
Assistant
It just took a while to build the runtime lib (first time). It worked and printed
2. Now let's run the DNS fixture with this wrapper.Assistant
This output matches Node's behavior exactly as described in the issue. Now let's verify the named import probe for the absent constants remains rejected.
Assistant
Named import rejection still works correctly. Now let's verify obvious unsupported call still gets rejected.
Assistant
Now let's run the existing relevant test suites to make sure nothing broke.
Assistant
All 12 tests pass, including the sweep tests. Let's also run the broader perry-hir test suite and perry-api-manifest tests, and manifest consistency test.
Assistant
Now let's run the full perry-hir test suite to ensure nothing else broke.
Assistant
Let's check the full summary count to be sure no failures elsewhere in the run (scroll up for other test files).
Assistant
All pass. Now let's also run the broader workspace test suite quickly for codegen and any DNS-related tests to be safe, plus check for existing dns tests elsewhere.
Assistant
Full workspace builds cleanly. Let's finally re-confirm the exact
perry checkcommand from the issue passes without env vars.Assistant
Let's view the final diff for review.
Assistant
I see stray build artifacts (
error-aliasesandtbinaries) created during testing. Let's remove them.Assistant
Clean. Let's also add a small regression test to make sure our fix is durable, verifying both the leniency and the retained strictness — matching the acceptance criterion "add or keep a regression test for that distinction." Let's check if there's a natural place, e.g., the
unimplemented_api_check.rstest file (though instructions say don't add tests). Let's re-read instructions about tests.Assistant
Property read passes as expected, while the call form remains rejected via the separate call-specific gate. This is exactly the desired distinction described in the issue. Let's clean any leftover temp/build artifacts and do a final review.
Assistant
Clean working tree with only intended changes. Let's do one final full check on the codegen test suite broadly (quick subset) to be extra safe, and re-run the whole perry-hir + perry-api-manifest + perry-codegen manifest tests once more for confidence.
Assistant
All tests pass across all affected crates. Now let's go through the checklist explicitly.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.