From bd169a1b31df3186c33907a42664b95d3a209d20 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 5 Mar 2024 08:54:13 -0800 Subject: [PATCH 1/2] don't prevent going to next stage when a warning is elevated to an error --- packages/compiler/src/core/program.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/compiler/src/core/program.ts b/packages/compiler/src/core/program.ts index 8ff5ae5eba..280b186f61 100644 --- a/packages/compiler/src/core/program.ts +++ b/packages/compiler/src/core/program.ts @@ -287,6 +287,7 @@ export async function compile( const loadedLibraries = new Map(); const sourceFileLocationContexts = new WeakMap(); let error = false; + let continueToNextStage = true; const logger = createLogger({ sink: host.logSink }); const tracer = createTracer(logger, { filter: options.trace }); @@ -382,7 +383,7 @@ export async function compile( program.checker = createChecker(program); program.checker.checkProgram(); - if (program.hasError()) { + if (!continueToNextStage) { return program; } // onValidate stage @@ -391,7 +392,7 @@ export async function compile( validateRequiredImports(); await validateLoadedLibraries(); - if (program.hasError()) { + if (!continueToNextStage) { return program; } @@ -1048,6 +1049,10 @@ export async function compile( return; } + if (diagnostic.severity === "error") { + continueToNextStage = false; + } + if (options.warningAsError && diagnostic.severity === "warning") { diagnostic = { ...diagnostic, severity: "error" }; } From 231ffa6311cfa595d3abd8a791b65a896c5ea2c8 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 5 Mar 2024 08:58:43 -0800 Subject: [PATCH 2/2] Create fix-warn-as-error-keep-going-2024-2-5-16-55-37.md --- .../fix-warn-as-error-keep-going-2024-2-5-16-55-37.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/fix-warn-as-error-keep-going-2024-2-5-16-55-37.md diff --git a/.chronus/changes/fix-warn-as-error-keep-going-2024-2-5-16-55-37.md b/.chronus/changes/fix-warn-as-error-keep-going-2024-2-5-16-55-37.md new file mode 100644 index 0000000000..92305cfcc5 --- /dev/null +++ b/.chronus/changes/fix-warn-as-error-keep-going-2024-2-5-16-55-37.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@typespec/compiler" +--- + +Warnings converted to error with `warn-as-error` do not prevent compilation from moving to the next stage like regular warnings