Skip to content

Commit 9f0ef6c

Browse files
quaesitor-scientiamPythonWillRuleclaude
authored
vfmt: prioritize internal error exit code (5) over format-diff exit codes (#26857)
When vfmt encounters both internal errors (e.g. TCC crash processing one file) and format differences in other files, the old code combined exit codes: 2 (format diffs with -c) + 5 (internal error) = 7. Exit code 7 is not handled by CI checks that tolerate `exit_code -ne 5`, causing false failures. Fix: when has_internal_error is true, exit(5) immediately before evaluating format-diff errors. The caller already retries with a better backend when exit code is 5; producing 7 prevents that recovery. Fixes: #26853 (Format vlang/v-analyzer CI step) Co-authored-by: Richard Wheeler <18647491+PythonWillRule@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3f7b77d commit 9f0ef6c

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎cmd/tools/vfmt.v‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,24 @@ fn main() {
145145
}
146146
errors++
147147
}
148-
ecode := if has_internal_error { 5 } else { 0 }
148+
if has_internal_error {
149+
// When some files could not be processed due to internal vfmt errors,
150+
// exit with code 5 regardless of format-diff errors in other files.
151+
// This prevents exit codes like 7 (2+5) that confuse downstream CI checks.
152+
exit(5)
153+
}
149154
if errors > 0 {
150155
if !foptions.is_diff {
151156
eprintln('Encountered a total of: ${errors} formatting errors.')
152157
}
153158
match true {
154-
foptions.is_noerror { exit(0 + ecode) }
155-
foptions.is_verify { exit(1 + ecode) }
156-
foptions.is_c { exit(2 + ecode) }
157-
else { exit(1 + ecode) }
159+
foptions.is_noerror { exit(0) }
160+
foptions.is_verify { exit(1) }
161+
foptions.is_c { exit(2) }
162+
else { exit(1) }
158163
}
159164
}
160-
exit(ecode)
165+
exit(0)
161166
}
162167

163168
fn (foptions &FormatOptions) verify_file(prefs &pref.Preferences, fpath string) bool {

0 commit comments

Comments
 (0)