mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 11:50:07 +00:00
Fix using issue #62
This commit is contained in:
+10
-7
@@ -439,6 +439,8 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_entity_use(c, expr, e);
|
||||||
|
|
||||||
switch (e->kind) {
|
switch (e->kind) {
|
||||||
case Entity_Alias: {
|
case Entity_Alias: {
|
||||||
if (e->Alias.original != NULL) {
|
if (e->Alias.original != NULL) {
|
||||||
@@ -506,17 +508,18 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
|
|||||||
|
|
||||||
case Entity_Variable: {
|
case Entity_Variable: {
|
||||||
Type *t = base_type(type_deref(e->type));
|
Type *t = base_type(type_deref(e->type));
|
||||||
if (is_type_struct(t) || is_type_raw_union(t)) {
|
if (is_type_struct(t) || is_type_raw_union(t) || is_type_union(t)) {
|
||||||
// TODO(bill): Make it work for unions too
|
// TODO(bill): Make it work for unions too
|
||||||
Scope **found = map_scope_get(&c->info.scopes, hash_pointer(t->Record.node));
|
Scope **found_ = map_scope_get(&c->info.scopes, hash_pointer(t->Record.node));
|
||||||
GB_ASSERT(found != NULL);
|
GB_ASSERT(found_ != NULL);
|
||||||
for_array(i, (*found)->elements.entries) {
|
Scope *found = *found_;
|
||||||
Entity *f = (*found)->elements.entries.e[i].value;
|
for_array(i, found->elements.entries) {
|
||||||
|
Entity *f = found->elements.entries.e[i].value;
|
||||||
if (f->kind == Entity_Variable) {
|
if (f->kind == Entity_Variable) {
|
||||||
Entity *uvar = make_entity_using_variable(c->allocator, e, f->token, f->type);
|
Entity *uvar = make_entity_using_variable(c->allocator, e, f->token, f->type);
|
||||||
if (is_selector) {
|
// if (is_selector) {
|
||||||
uvar->using_expr = expr;
|
uvar->using_expr = expr;
|
||||||
}
|
// }
|
||||||
Entity *prev = scope_insert_entity(c->context.scope, uvar);
|
Entity *prev = scope_insert_entity(c->context.scope, uvar);
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
gbString expr_str = expr_to_string(expr);
|
gbString expr_str = expr_to_string(expr);
|
||||||
|
|||||||
@@ -4696,6 +4696,7 @@ irValue *ir_get_using_variable(irProcedure *proc, Entity *e) {
|
|||||||
if (pv != NULL) {
|
if (pv != NULL) {
|
||||||
v = *pv;
|
v = *pv;
|
||||||
} else {
|
} else {
|
||||||
|
GB_ASSERT_MSG(e->using_expr != NULL, "%.*s", LIT(name));
|
||||||
v = ir_build_addr(proc, e->using_expr).addr;
|
v = ir_build_addr(proc, e->using_expr).addr;
|
||||||
}
|
}
|
||||||
GB_ASSERT(v != NULL);
|
GB_ASSERT(v != NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user