Skip to content

Fixed (Critical null pointer bug) in incremental builder #61807

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ function releaseCache(state: BuilderProgramState) {
* Verifies that source file is ok to be used in calls that arent handled by next
*/
function assertSourceFileOkWithoutNextAffectedCall(state: BuilderProgramState, sourceFile: SourceFile | undefined) {
Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex! - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[(state.affectedFilesIndex ?? 0) - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
}

/**
Expand All @@ -641,7 +641,7 @@ function getNextAffectedFile(
const { affectedFiles } = state;
if (affectedFiles) {
const seenAffectedFiles = state.seenAffectedFiles!;
let affectedFilesIndex = state.affectedFilesIndex!; // TODO: GH#18217
let affectedFilesIndex = state.affectedFilesIndex ?? 0; // Fixed: properly handle undefined case
while (affectedFilesIndex < affectedFiles.length) {
const affectedFile = affectedFiles[affectedFilesIndex];
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
Expand Down Expand Up @@ -1845,8 +1845,8 @@ export function createBuilderProgram(
// update affected files
const affectedSourceFile = affected as SourceFile;
state.seenAffectedFiles!.add(affectedSourceFile.resolvedPath);
if (state.affectedFilesIndex !== undefined) state.affectedFilesIndex++;
// Change in changeSet/affectedFilesPendingEmit, buildInfo needs to be emitted
state.affectedFilesIndex = (state.affectedFilesIndex ?? 0) + 1;
// Change in changeSet, buildInfo needs to be emitted
state.buildInfoEmitPending = true;
// Update the pendingEmit for the file
const existing = state.seenEmittedFiles?.get(affectedSourceFile.resolvedPath) || BuilderFileEmit.None;
Expand Down Expand Up @@ -2145,7 +2145,7 @@ export function createBuilderProgram(
result = getSemanticDiagnosticsOfFile(state, affectedSourceFile, cancellationToken);
}
state.seenAffectedFiles!.add(affectedSourceFile.resolvedPath);
state.affectedFilesIndex!++;
state.affectedFilesIndex = (state.affectedFilesIndex ?? 0) + 1;
// Change in changeSet, buildInfo needs to be emitted
state.buildInfoEmitPending = true;
if (!result) continue;
Expand Down