bugfix with new package aliases
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 21 May 2022 03:23:37 +0000 (22:23 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 21 May 2022 03:23:37 +0000 (22:23 -0500)
src/symres.c

index 01a86c16d2f789ad84ff034c1a592cf1088127e1..5b3ea1bb9bb2e64057fca68858749e881127e5a7 100644 (file)
@@ -309,10 +309,23 @@ static SymresStatus symres_field_access(AstFieldAccess** fa) {
     AstTyped* expr = (AstTyped *) strip_aliases((AstNode *) (*fa)->expr);
 
     b32 force_a_lookup = 0;
+
     if (expr->kind == Ast_Kind_Enum_Type || expr->kind == Ast_Kind_Type_Raw_Alias) {
         force_a_lookup = 1;
     }
 
+    //
+    // If we are trying to access a field on an alias, we have to make sure
+    // the alias is "ready" to have a symbol looked up inside of it. This means
+    // the alias should have passed symbol resolution. If not, force a lookup
+    // and yield if the alias was not ready.
+    if ((*fa)->expr->kind == Ast_Kind_Alias) {
+        assert((*fa)->expr->entity);
+        if ((*fa)->expr->entity->state < Entity_State_Check_Types) {
+            force_a_lookup = 1;
+        }
+    }
+
     AstNode* resolution = try_symbol_resolve_from_node((AstNode *) expr, (*fa)->token);
     if (resolution) *((AstNode **) fa) = resolution;
     else if (expr->kind == Ast_Kind_Package) {