From b4d08925f299ae0589c2af1900c7326e51c8a059 Mon Sep 17 00:00:00 2001 From: gco Date: Sun, 11 Oct 2026 10:59:09 +1100 Subject: [PATCH] fix complier error from alias of named union example ```odin Scope :: any_dec any_dec :: union { ^type_incomplete_declaration, ^type_enum_declaration, ... sym_scope :: struct { syms : map[StrHandle][dynamic]symbol, parent_scope : Scope, } sym_scope_make :: proc(parent : Scope, alloc : mem.Allocator) -> sym_scope { return sym_scope{make(map[StrHandle][dynamic]symbol, 0, alloc), parent} ---sometimes error here } ``` depending on where the alias was declared, can output ``` Error: Cannot assign value 'parent' of type 'any_dec' to 'union {^type_incomplete_declaration, ...}' in a structure literal ... sym_scope{make(map[StrHandle][dynamic]symbol, 0, alloc), parent} ``` haven't been able to recreate a minimal reproduceable test case yet --- src/check_expr.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 6f6f7da70..dea7d5a06 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1998,7 +1998,12 @@ gb_internal Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *nam } // Keep struct aliases named so recursive fields retain their alias edge. if (bt != nullptr && bt->kind != Type_Struct) { - o->type = bt; + if (bt->kind == Type_Union) { + o->type = base_named_type(o->type); + } + else { + o->type = bt; + } } } break;