Skip to content

Prevent crash when computing emit output paths - #4900

Draft
Daniel Rosenwasser (DanielRosenwasser) with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-crash-getsourcefilepathinnewdir
Draft

Prevent crash when computing emit output paths#4900
Daniel Rosenwasser (DanielRosenwasser) with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-crash-getsourcefilepathinnewdir

Conversation

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

GetSourceFilePathInNewDir could panic when normalized path containment succeeded but the raw common-directory string was longer than the source path, causing an out-of-bounds slice.

  • Output path handling

    • Delegate to GetSourceFilePathInNewDirWorker, matching the TypeScript reference implementation’s canonical prefix behavior.
    • Remove the inconsistent structural containment check.
  • Regression coverage

    • Cover a source path equal to the common source directory, including its trailing separator.

Copilot AI and others added 4 commits August 13, 2026 22:17
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix crash at GetSourceFilePathInNewDir Prevent crash when computing emit output paths Aug 13, 2026
@DanielRosenwasser

Copy link
Copy Markdown
Member

Copilot this really needs an integration/compiler test as well.

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Copilot this really needs an integration/compiler test as well.

Added compiler regression coverage in 6e4cd80. The test reproduces the pre-fix slice bounds out of range panic and passes with the fix.

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.

Crash at GetSourceFilePathInNewDir

2 participants