Skip to content

fix(compiler): resolve reference paths with ResolveFile to stop a VFS panic - #1057

Merged
camc314 merged 2 commits into
oxc-project:mainfrom
magurotuna:fix/reference-path-resolve-file
Nov 20, 2026
Merged

camc314 merged 2 commits into
oxc-project:mainfrom
magurotuna:fix/reference-path-resolve-file

Conversation

@magurotuna

Copy link
Copy Markdown
Member

/// <reference path="C:" /> made tsrs panic with vfs: path "C:.ts" is not absolute, where tsgo reports TS6231. A reference path that ends with / ("./x/" for x.ts) reported TS6231 or TS6054, and declaration emit dropped it. tsgo finds the file.

Go resolves the name with RootedDirectoryPath.ResolveFile in the file loader and in GetSourceFileFromReference. It ends a path that is only a root with / and removes a trailing /. tsrs used normalize_path and resolve_path, which do neither, so it looked up C:.ts and x/.ts. This PR ports ResolveFile and ToRootedPath as tspath::resolve_file and tspath::to_rooted_path, and uses resolve_file at both call sites.

Tests: the reference-path-drive-root and reference-path-trailing-slash regressions, and reference_path_resolve_file in tsrs_cli (declaration emit). All fail without the fix.

AI assistance: written with Claude Code.

… panic

`/// <reference path="C:" />` made tsrs panic with `vfs: path "C:.ts" is
not absolute`, where tsgo reports TS6231. A reference path that ends with
`/` (`"./x/"` for `x.ts`) reported TS6231 or TS6054, and declaration emit
dropped it. tsgo finds the file.

Go resolves the name with `RootedDirectoryPath.ResolveFile`
(`tspath/rooted_path.go:727`) in the file loader and in
`GetSourceFileFromReference`. It ends a path that is only a root with `/`
and removes a trailing `/`. tsrs used `normalize_path` and `resolve_path`,
which do neither, so it looked up `C:.ts` and `x/.ts`. Port `ResolveFile`
and `ToRootedPath` as `tspath::resolve_file` and `tspath::to_rooted_path`,
and use `resolve_file` at both call sites.

Tests: the `reference-path-drive-root` and `reference-path-trailing-slash`
regressions, and `reference_path_resolve_file` in `tsrs_cli` (declaration
emit). All fail without the fix.

AI assistance: written with Claude Code.
@camc314
camc314 enabled auto-merge November 20, 2026 17:06
@camc314
camc314 added this pull request to the merge queue Nov 20, 2026
Merged via the queue into oxc-project:main with commit 3304886 Nov 20, 2026
69 checks passed
@codspeed

codspeed Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

βœ… 8 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing magurotuna:fix/reference-path-resolve-file (47219b4) with main (4d59429)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants