aboutsummaryrefslogtreecommitdiff
path: root/src/check_stmt.cpp
diff options
context:
space:
mode:
authorColin Davidson <colrdavidson@gmail.com>2025-06-08 16:17:32 -0700
committerColin Davidson <colrdavidson@gmail.com>2025-06-08 16:17:32 -0700
commit04481e0fd289f854e35a84da909184140940bbf7 (patch)
tree97224c25709866edbf16a486fdbd30a4d736701a /src/check_stmt.cpp
parentb1ed22d84f2aae617c90c60701e9f25345cab980 (diff)
parent7813e9fb378753bf110f0ad4b5cc85e7f16336d4 (diff)
Merge branch 'master' into macharena
Diffstat (limited to 'src/check_stmt.cpp')
-rw-r--r--src/check_stmt.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index 1b44ff4d7..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) {
@@ -2108,10 +2122,12 @@ gb_internal void check_value_decl_stmt(CheckerContext *ctx, Ast *node, u32 mod_f
if (init_type == nullptr) {
init_type = t_invalid;
} else if (is_type_polymorphic(base_type(init_type))) {
+ /* DISABLED: This error seems too aggressive for instantiated generic types.
gbString str = type_to_string(init_type);
error(vd->type, "Invalid use of a polymorphic type '%s' in variable declaration", str);
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];
@@ -2853,6 +2869,7 @@ gb_internal void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags)
case Ast_BlockStmt:
case Ast_IfStmt:
case Ast_SwitchStmt:
+ case Ast_TypeSwitchStmt:
if (token.kind != Token_break) {
error(bs->label, "Label '%.*s' can only be used with 'break'", LIT(e->token.string));
}