diff options
| author | gingerBill <bill@gingerbill.org> | 2022-11-01 13:03:35 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-11-01 13:03:35 +0000 |
| commit | 411c0add3b2394a222ff341d88aef512c554c050 (patch) | |
| tree | f84e11fd7217d9f03dc839e15f4519ec5bf8068f /src/checker.cpp | |
| parent | 4812601e78c10d656ab53ec80fa3fb496a8da5b2 (diff) | |
Add safety check for #2161
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 5bdc5b010..9b2f72205 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1673,7 +1673,14 @@ bool could_entity_be_lazy(Entity *e, DeclInfo *d) { } void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported) { - GB_ASSERT(identifier->kind == Ast_Ident); + GB_ASSERT(identifier != nullptr); + if (identifier->kind != Ast_Ident) { + // NOTE(bill): This is a safety check + gbString s = expr_to_string(identifier); + error(identifier, "A variable declaration must be an identifer, got %s", s); + gb_string_free(s); + return; + } GB_ASSERT(e != nullptr && d != nullptr); GB_ASSERT(identifier->Ident.token.string == e->token.string); |