diff options
| author | gingerBill <bill@gingerbill.org> | 2024-07-10 13:45:21 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-07-10 13:45:21 +0100 |
| commit | c54e3d3c4f3d32761c17e3528714598717ecebbd (patch) | |
| tree | 33e8e0af2ccfc4fbc1862b8f52d8ba4b23573f43 /src/check_stmt.cpp | |
| parent | 38315f83dad49d89277fc3ba459b6e7c28ff098e (diff) | |
Improve warning handling for possible `default:` typo
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index edf2fae39..f4d3bd6b8 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -2031,6 +2031,12 @@ gb_internal void check_value_decl_stmt(CheckerContext *ctx, Ast *node, u32 mod_f gb_string_free(str); init_type = t_invalid; } + if (init_type == t_invalid && entity_count == 1 && (mod_flags & (Stmt_BreakAllowed|Stmt_FallthroughAllowed))) { + Entity *e = entities[0]; + if (e != nullptr && e->token.string == "default") { + warning(e->token, "Did you mean 'case:'?"); + } + } } |