Browse Source

Fix `using` with `bit_field`

gingerBill 6 years ago
parent
commit
0778d18bc7
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/check_type.cpp

+ 2 - 2
src/check_type.cpp

@@ -40,7 +40,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 != "_") {
+			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);
@@ -59,7 +59,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 != "_") {
+			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);