aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-01-02 23:55:21 +0000
committergingerBill <bill@gingerbill.org>2019-01-02 23:55:21 +0000
commitcda0f4d8f37e738af30141c134419c412a580e0c (patch)
tree53752a86399e4620fdd7bbfa30804643b54dfe64 /src/check_type.cpp
parent0546b5c218a877cd5debdd3aaf051ceaf29bd304 (diff)
Fix `using` struct cycle check
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 1acf379a7..65a546e5e 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -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) {
+ if (t == nullptr) {
+ return;
+ }
t = base_type(type_deref(t));
gbString str = nullptr;
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);
String name = f->token.string;
Entity *e = scope_lookup_current(ctx->scope, name);
- if (e != nullptr && name != "_" && e != f) {
+ if (e != nullptr && name != "_") {
// TODO(bill): Better type error
if (str != nullptr) {
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];
String name = f->token.string;
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
if (str != nullptr) {
error(e->token, "'%.*s' is already declared in '%s'", LIT(name), str);