diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-04 14:00:33 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-04 14:00:33 -0400 |
| commit | d046214f67baf9c580605fa4294818e7a12fc434 (patch) | |
| tree | 2aa4835232e4fa906cdddf84592336510503509b /src | |
| parent | 6804f4c4716c65f2729945de3e7b7413fb061ee1 (diff) | |
Be strict with type switch case column alignment too
This copies the same block used for regular switch cases.
Fixes #4673
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_stmt.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 6cacef3ee..d92edf41d 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1593,6 +1593,20 @@ gb_internal void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_ error_line("\tSuggestion: Was '#partial switch' wanted?\n"); } } + + if (build_context.strict_style) { + Token stok = ss->token; + for_array(i, bs->stmts) { + Ast *stmt = bs->stmts[i]; + if (stmt->kind != Ast_CaseClause) { + continue; + } + Token ctok = stmt->CaseClause.token; + if (ctok.pos.column > stok.pos.column) { + error(ctok, "With '-strict-style', 'case' statements must share the same column as the 'switch' token"); + } + } + } } gb_internal void check_block_stmt_for_errors(CheckerContext *ctx, Ast *body) { |