Skip to content

fix: #810 — path.posix.* and path.win32.join sub-namespace dispatch#817

Merged
proggeramlug merged 1 commit into
mainfrom
worktree-fix-810-path-subns
May 16, 2026
Merged

fix: #810 — path.posix.* and path.win32.join sub-namespace dispatch#817
proggeramlug merged 1 commit into
mainfrom
worktree-fix-810-path-subns

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

  • path.posix.<method>(...) and path.win32.<method>(...) returned undefined because the sub-namespace shape was excluded from the generic mod.X.Y() arm with no replacement lowering.
  • Adds HIR lowering that routes path.posix.* to the existing POSIX Expr::Path* variants (direct shape rewrite — runtime is already POSIX) and routes path.win32.join to a new Expr::PathWin32Join backed by a dedicated js_path_win32_join runtime function that joins with \ and normalizes drive letters / mixed separators.
  • test_parity_path.ts is now a full byte-for-byte PASS against node --experimental-strip-types.

Scope notes

  • Methods covered for posix: join, dirname, basename, basenameExt, extname, resolve, isAbsolute, relative, normalize, parse, format, toNamespacedPath, matchesGlob.
  • Methods covered for win32: join only. Other path.win32.* methods are intentionally left unwired — falling them through to the POSIX runtime would silently mis-handle drive letters and \ segments. Track those in a follow-up if needed.

Test plan

  • 4-line repro from the issue prints output matching Node (posix.join: /foo/bar, win32.join: C:\foo\bar).
  • test-files/test_parity_path.ts diff vs Node is empty.
  • cargo test --release -p perry-hir -p perry-codegen passes.

Closes #810.

`path.posix.<method>(...)` and `path.win32.<method>(...)` previously fell
through to the receiver-less dispatch and returned `undefined`, because
the sub-namespace shape `<root>.<sub>.<method>(args)` was on the strict-API
exclusion list of the generic `mod.X.Y()` arm but had no replacement
lowering arm.

Adds:

- HIR `Expr::PathWin32Join(a, b)` and runtime `js_path_win32_join` that
  joins with `\` separators and normalizes drive letters / mixed `/`+`\`
  segments per Node's win32 semantics.
- HIR lowering for `path.posix.<method>(args)` — routes to the existing
  POSIX `Expr::Path*` variants (the runtime functions are already
  POSIX-shaped, so this is a direct shape rewrite for join, dirname,
  basename, extname, resolve, isAbsolute, relative, normalize, parse,
  format, toNamespacedPath, matchesGlob).
- HIR lowering for `path.win32.join(args)` — routes to the new
  `Expr::PathWin32Join`. Other `path.win32.*` methods are intentionally
  left unwired here; falling them through to the POSIX runtime would
  silently mis-handle drive letters and `\` segments. Track those in a
  follow-up.

`test_parity_path.ts` now passes byte-for-byte against
`node --experimental-strip-types`.
@proggeramlug proggeramlug merged commit a290091 into main May 16, 2026
9 checks passed
@proggeramlug proggeramlug deleted the worktree-fix-810-path-subns branch May 16, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path.posix / path.win32 sub-namespace methods return undefined (last gap before path PASS)

1 participant