@@ -979,35 +979,31 @@ fn processAssociatedItemsSecondPass(
979979 // Create anno-only def with the qualified name
980980 const def_idx = try self .createAnnoOnlyDef (qualified_idx , type_anno_idx , where_clauses , region );
981981
982- // Get the type annotation index from the def - this is what has the actual type!
983- // For anno-only defs, the expr is e_anno_only which doesn't have a type; the type anno has it.
984- const def_cir = self .env .store .getDef (def_idx );
985- const annotation_idx = def_cir .annotation .? ;
986- const annotation_cir = self .env .store .getAnnotation (annotation_idx );
987- const type_anno_node_idx = annotation_cir .anno ;
988- const type_anno_idx_u16 : u16 = @intCast (@intFromEnum (type_anno_node_idx ));
989-
982+ // Store the DEF index (not the type annotation index) for lookup
983+ // The interpreter needs to find the def, which contains the expression to evaluate
984+ const def_idx_u16 : u16 = @intCast (@intFromEnum (def_idx ));
990985
991- // Register this associated item by its unqualified name using the TYPE ANNOTATION index
986+ // Register this associated item by its unqualified name using the DEF index
992987 // (e.g., "is_empty" not "Str.is_empty")
993- try self .env .setExposedNodeIndexById (name_ident , type_anno_idx_u16 );
988+ try self .env .setExposedNodeIndexById (name_ident , def_idx_u16 );
994989
995990 // Compute type-qualified name (e.g., "Str.is_empty")
996991 const type_qualified_idx = try self .env .insertQualifiedIdent (self .env .getIdent (parent_type_name ), name_text );
997992
998- // Always register by the type-qualified name (e.g., "Str.is_empty") using TYPE ANNOTATION index
993+ // Always register by the type-qualified name (e.g., "Str.is_empty") using DEF index
999994 // This is needed so lookups like "Str.is_empty" work from other modules
1000995 if (type_qualified_idx .idx != name_ident .idx ) {
1001- try self .env .setExposedNodeIndexById (type_qualified_idx , type_anno_idx_u16 );
996+ try self .env .setExposedNodeIndexById (type_qualified_idx , def_idx_u16 );
1002997 }
1003998
1004- // Also ALWAYS register by the fully qualified name (e.g., "Builtin.Str.is_empty") using TYPE ANNOTATION index
999+ // Also ALWAYS register by the fully qualified name (e.g., "Builtin.Str.is_empty") using DEF index
10051000 // This is needed for nested types inside regular modules (not just type modules)
10061001 if (qualified_idx .idx != type_qualified_idx .idx and qualified_idx .idx != name_ident .idx ) {
1007- try self .env .setExposedNodeIndexById (qualified_idx , type_anno_idx_u16 );
1002+ try self .env .setExposedNodeIndexById (qualified_idx , def_idx_u16 );
10081003 }
10091004
10101005 // Make the real pattern available in current scope (replaces placeholder)
1006+ const def_cir = self .env .store .getDef (def_idx );
10111007 const pattern_idx = def_cir .pattern ;
10121008 const current_scope = & self .scopes .items [self .scopes .items .len - 1 ];
10131009
0 commit comments