mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix using struct cycle check
This commit is contained in:
+5
-2
@@ -27,6 +27,9 @@ void populate_using_array_index(CheckerContext *ctx, Ast *node, AstField *field,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void populate_using_entity_scope(CheckerContext *ctx, Ast *node, AstField *field, Type *t) {
|
void populate_using_entity_scope(CheckerContext *ctx, Ast *node, AstField *field, Type *t) {
|
||||||
|
if (t == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
t = base_type(type_deref(t));
|
t = base_type(type_deref(t));
|
||||||
gbString str = nullptr;
|
gbString str = nullptr;
|
||||||
defer (gb_string_free(str));
|
defer (gb_string_free(str));
|
||||||
@@ -40,7 +43,7 @@ void populate_using_entity_scope(CheckerContext *ctx, Ast *node, AstField *field
|
|||||||
GB_ASSERT(f->kind == Entity_Variable);
|
GB_ASSERT(f->kind == Entity_Variable);
|
||||||
String name = f->token.string;
|
String name = f->token.string;
|
||||||
Entity *e = scope_lookup_current(ctx->scope, name);
|
Entity *e = scope_lookup_current(ctx->scope, name);
|
||||||
if (e != nullptr && name != "_" && e != f) {
|
if (e != nullptr && name != "_") {
|
||||||
// TODO(bill): Better type error
|
// TODO(bill): Better type error
|
||||||
if (str != nullptr) {
|
if (str != nullptr) {
|
||||||
error(e->token, "'%.*s' is already declared in '%s'", LIT(name), str);
|
error(e->token, "'%.*s' is already declared in '%s'", LIT(name), str);
|
||||||
@@ -59,7 +62,7 @@ void populate_using_entity_scope(CheckerContext *ctx, Ast *node, AstField *field
|
|||||||
Entity *f = t->BitField.fields[i];
|
Entity *f = t->BitField.fields[i];
|
||||||
String name = f->token.string;
|
String name = f->token.string;
|
||||||
Entity *e = scope_lookup_current(ctx->scope, name);
|
Entity *e = scope_lookup_current(ctx->scope, name);
|
||||||
if (e != nullptr && name != "_" && e != f) {
|
if ((e != nullptr && name != "_") && (e != f)) {
|
||||||
// TODO(bill): Better type error
|
// TODO(bill): Better type error
|
||||||
if (str != nullptr) {
|
if (str != nullptr) {
|
||||||
error(e->token, "'%.*s' is already declared in '%s'", LIT(name), str);
|
error(e->token, "'%.*s' is already declared in '%s'", LIT(name), str);
|
||||||
|
|||||||
Reference in New Issue
Block a user