Skip to content

Do not create SourceFiles for non-existent files #1148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 10, 2025

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Jun 10, 2025

Noticed this while working on another PR. We were treating all not-found files as empty.

Perhaps this is just papering over some places we don't precheck that a file exists? No, Strada had getSourceFile(...): SourceFile | undefined.

@Copilot Copilot AI review requested due to automatic review settings June 10, 2025 08:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR prevents the creation of SourceFiles for files that do not exist by adding an existence check before proceeding with file processing. Key changes include:

  • Returning nil instead of a SourceFile in both internal/testutil/harnessutil/harnessutil.go and internal/compiler/host.go when the file isn't found.
  • Updating baseline test files by removing redundant or extraneous marker lines.

Reviewed Changes

Copilot reviewed 51 out of 51 changed files in this pull request and generated no comments.

Show a summary per file
File Description
testdata/baselines/reference/submodule/conformance/parserRealSource10.js.diff Adjusted skipped-lines markers and removed an extra marker.
testdata/baselines/reference/submodule/conformance/parserRealSource10.js Removed an unwanted marker line.
testdata/baselines/reference/submodule/conformance/parserRealSource1.js.diff Removed baseline markers and updated skipped-lines counts.
testdata/baselines/reference/submodule/conformance/parserRealSource1.js Removed an unwanted marker line.
testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js.diff Removed duplicated marker line.
testdata/baselines/reference/submodule/compiler/selfReferencingFile2.js Removed duplicated marker line.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff Removed an unnecessary reference comment and marker.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js Removed an unnecessary marker line.
testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js.diff Removed test lines associated with non-existent references.
testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.js Removed test lines associated with non-existent references.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff Adjusted reference comment and removed redundant marker.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js Removed redundant marker line.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff Adjusted reference comment and removed redundant marker.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js Removed redundant marker line.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js.diff Removed extraneous marker lines from reference tests.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.js Removed extraneous marker lines from reference tests.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js.diff Removed extraneous marker lines from reference tests.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference.js Removed extraneous marker lines from reference tests.
internal/testutil/harnessutil/harnessutil.go Added a file existence check to avoid creating a SourceFile for non-existent files.
internal/compiler/host.go Added a file existence check to avoid creating a SourceFile for non-existent files.

Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had done this change in #1078 where some of my changes werent working properly because of this

@jakebailey jakebailey requested a review from sheetalkamat June 10, 2025 17:03
@jakebailey jakebailey enabled auto-merge June 10, 2025 17:08
@jakebailey jakebailey added this pull request to the merge queue Jun 10, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jun 10, 2025
@jakebailey jakebailey enabled auto-merge June 10, 2025 17:42
@jakebailey
Copy link
Member Author

CI race failure is #1151.

@jakebailey jakebailey added this pull request to the merge queue Jun 10, 2025
Merged via the queue into main with commit d145105 Jun 10, 2025
23 checks passed
@jakebailey jakebailey deleted the jabaile/file-not-found branch June 10, 2025 18:55
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.

2 participants