Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Node API checker: namespace reads of absent builtin exports should…

  1. 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/promises intentionally does not export ADDRCONFIG, V4MAPPED, or ALL, but reading those properties from the namespace object is valid in Node and returns undefined. 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 ECANCELLED
    

    Node 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:48
    

    The manifest matches Node for named exports: dns/promises includes DNS error aliases like NODATA and CANCELLED, but does not include ADDRCONFIG, V4MAPPED, or ALL.

    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 ECANCELLED
    

    The relevant gate is in crates/perry-hir/src/lower/expr_member.rs: namespace PropertyGet on a NativeModuleRef(module) fails whenever module_has_symbol(module, prop) is None, even when the Node-compatible value for a namespace property miss is simply undefined.

    Scope

    Make Node built-in namespace property reads distinguishable from named imports/calls:

    • import * as dnsPromises from "node:dns/promises"; dnsPromises.ADDRCONFIG should compile and evaluate to undefined, 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.ts passes without PERRY_ALLOW_UNIMPLEMENTED=1.
    • The DNS constants fixture prints the same shape as Node for:
      • absent dns/promises.ADDRCONFIG, V4MAPPED, and ALL namespace reads (undefined), and
      • present DNS error aliases (NODATA, CANCELLED, etc.).
    • 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:dns and node:dns/promises.
    • This issue tracks the separate property-read/static-gate mismatch that currently blocks the expanded DNS constants fixture.

    Interface

    No new interfaces are introduced.

    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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Build succeeded. Let's reproduce the issue first.

  3. Claude Assistant

    Reproduced. Now let's check the fixture for named import test that should still fail:

  4. Claude Assistant

    Now let's check named import rejection mechanism — how named imports of absent exports are currently rejected. Let's search.

  5. Claude Assistant

    That confirms named import rejection already exists separately (module_decl.rs). Good, so this issue is purely about namespace property reads. Let's look at that region to confirm it doesn't get affected by our change.

  6. Claude Assistant

    Good, confirms my analysis. Now let's check a bare property read for an absent property that isn't a call, e.g. fs.notARealProp (value only) currently also errors:

  7. Claude Assistant

    Let's find the LoweringContext struct definition to add a new field.

  8. Claude Assistant

    Now let's add a new field member_call_callee_once to track whether the current member expr lowering is the direct callee of a call (so gate stays strict).

  9. Claude Assistant

    Need to open the file first.

  10. Claude Assistant

    Now let's find the initializer in context.rs to set the default value.

  11. Claude Assistant

    Now let's set the flag at the call-site in expr_call/mod.rs before the tail lower_expr(ctx, expr)?.

  12. Claude Assistant

    Let's use edit command via the editor instead, opening the file at that line range.

  13. Claude Assistant

    Now edit lines 1810-1832 to add the relaxation logic.

  14. Claude Assistant

    Good, that worked. Now let's build.

  15. Claude Assistant

    Build succeeded. Now let's re-test the issue scenarios.

  16. Claude Assistant

    Now let's confirm the fs.notARealMethod() call regression test still errors, and bare property read of unsupported module still returns undefined.

  17. Claude Assistant

    Now confirm the fs bad call case in isolation still errors.

  18. Claude Assistant

    Both behaviors confirmed as required. Now let's test named import rejection for absent export still works.

  19. Claude Assistant

    Excellent, matches Node's behavior. Now let's run the fixture with perry run to check runtime output matches expectations.

  20. Claude Assistant

    Confirmed pre-existing environment issue unrelated to our change. Let's restore our changes.

  21. Claude Assistant

    Now that clang-16 works, let's run the actual fixture and confirm output matches expected shape.

  22. Claude Assistant

    This output matches Node's expected shape exactly (as described in the issue). Now let's run relevant existing tests to make sure nothing broke.

  23. Claude Assistant

    Confirmed dns.ADDRCONFIG is a Property entry (twice, likely duplicated entries but same module "dns"). Now let's implement the sibling-module heuristic.

  24. Claude Assistant

    Let's use heredoc syntax instead since direct parameter passing with special chars fails.

  25. Claude Assistant

    Now let's update the gate in expr_member.rs to use this new function.

  26. Claude Assistant

    There's a duplicate leftover from the old edit (lines 1864-1868). Let's remove those.

  27. Claude Assistant

    Good, cleaned up now. Let's rebuild and rerun the test suite.

  28. Claude Assistant

    Build succeeded. Now let's re-run all our checks.

  29. Claude Assistant

    All four scenarios now behave correctly (fixture passes, both bare-property-miss and call-miss on truly unimplemented fs API still error, named import still rejected). Now run the full existing test suite.

  30. Claude Assistant

    All 12 tests pass now. Let's run the broader perry-hir test suite and other related crates to ensure no regressions.

  31. Claude Assistant

    All perry-hir tests pass. Let's check whole test result summary (any failures higher up).

  32. Claude Assistant

    All pass. Let's also run perry-api-manifest, perry-codegen and full workspace tests (this might take long, but let's check key ones).

  33. Claude Assistant

    All green. Let's also run the full workspace test suite to be thorough (excluding integration tests requiring the LLVM backend that we know might time out), focusing on unit-level crates.

  34. Claude Assistant

    All pass. Now let's also run the perry crate's test suite (integration tests) if feasible, and check the test-parity node-suite tests more broadly for regressions relating to dns/promises.

  35. Claude Assistant

    All pass. Let's also check test-files/test_parity_dns_promises.ts and test_parity_dns.ts still check fine.

  36. Claude Assistant

    Good, escape hatch still works. Now let's also run the full perry check against a broader parity suite quickly to catch any regressions across other modules.

  37. Claude Assistant

    14 errors before (includes the DNS constants one), 13 after (that one fixed). Let's diff to confirm exactly one error was removed and no new ones introduced.

  38. Claude Assistant

    I accidentally replaced the em-dash with -- in the actual error message string. Let's fix that back to the original em dash character.

  39. Claude Assistant

    Now let's clean up my comments that used -- instead of em-dash for consistency, though those are just comments (not critical, but let's tidy for style consistency). Let's check remaining -- occurrences I introduced.

  40. Claude Assistant

    Good, no more occurrences (grep exit 1 = no matches). Now rebuild and re-verify everything.

  41. Claude Assistant

    Now the only diff is the exact intended fix — the dns/promises.ADDRCONFIG error is gone, nothing else changed (em-dash consistent). Let's re-run cargo tests once more to confirm everything still passes.

  42. Claude Assistant

    All passing. Now let's re-verify the fixture check and run scenarios once more, and also run the fixture with runtime execution (using clang-16) for final confirmation.

  43. Claude Assistant

    Everything checks out. Let's view the full diff of changes for review.

  44. Claude Assistant

    Clean. Let's do a final full re-verification pass to be safe.

  45. Claude Assistant

    Everything passes. Let's go through the checklist explicitly.

  46. Claude Assistant

    Checklist review:

    • Reproduced the reported error: Yes — ran perry check test-parity/node-suite/dns/constants/error-aliases.ts before any changes and confirmed the exact U006: dns/promises.ADDRCONFIG is not implemented error from the issue.
    • Confirmed the fix resolves the error: Yes — after the fix, perry check passes cleanly on that fixture, and perry run (using a newer clang I installed to work around an unrelated environment limitation) produces output matching Node's documented behavior exactly (undefined for dnsPromises.ADDRCONFIG/V4MAPPED/ALL, correct string values for real aliases like NODATA/CANCELLED).
    • Thought about edge cases:
      • Kept named ESM import rejection for absent exports intact (import { ADDRCONFIG } from "node:dns/promises" still errors, verified).
      • Kept the strict unimplemented-API gate for actual method calls (fs.notARealMethod() still errors) via the new member_call_callee_once one-shot flag.
      • Restricted the read-side leniency to only fire when the property is a genuinely registered export on a sibling module in the same family (dns/dns/promises, fs/fs/promises, path/path/posix/path/win32, util/util/types, etc.) — so arbitrary bogus/typo'd properties (crypto.foobar, axios.foo, fs.notARealProp) still error, matching all pre-existing tests' intent instead of blanket-relaxing every property miss.
      • Verified the PERRY_ALLOW_UNIMPLEMENTED=1 escape hatch still works.
      • Ran a full check sweep over test-parity/node-suite (2500+ files) before/after and diffed error output — only the targeted dns/promises.ADDRCONFIG error disappeared; nothing else changed.
  47. Claude Assistant
    • Ran existing tests affected by the change and confirmed they pass: Yes — perry-hir (all 12 tests in unimplemented_api_check.rs plus the full crate's 132+ other tests), perry-api-manifest, and perry-codegen test suites all pass with zero failures.

    Everything looks good. Let's do one final sanity check of the diff and submit.

  48. Claude Assistant

    This diff is focused, well-documented, and addresses the issue precisely while preserving all existing safety guarantees. Let's submit.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.