File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -609,8 +609,14 @@ impl Environment<'_> {
609609 // Check this in the hydrator, i.e. is it a created type
610610 let v = self . new_unbound_var ( ) ;
611611 let _ = ids. insert ( * id, v. clone ( ) ) ;
612- let new_id = self . previous_uid ( ) ;
613- self . names . map_new_variable ( * id, new_id) ;
612+
613+ // Preserve any user-provided name from the original generic variable
614+ // for the new unbound variable. This ensures error messages and type
615+ // displays continue to use meaningful names (e.g., "something") rather
616+ // than auto-generated ones (e.g., "a", "b").
617+ let v_id = self . previous_uid ( ) ;
618+ self . names . reassign_type_variable_alias ( * id, v_id) ;
619+
614620 return v;
615621 }
616622 }
Original file line number Diff line number Diff line change @@ -208,9 +208,11 @@ impl Names {
208208 _ = self . type_variables . insert ( id, local_alias. clone ( ) ) ;
209209 }
210210
211- pub fn map_new_variable ( & mut self , old_id : u64 , new_id : u64 ) {
212- if let Some ( alias) = self . type_variables . get ( & old_id) {
213- _ = self . type_variables . insert ( new_id, alias. clone ( ) ) ;
211+ /// Assigns `source_id` alias to `target_id`. This is useful when type variables are unified
212+ /// and we need to preserve the original name for consistent error messages and type display.
213+ pub fn reassign_type_variable_alias ( & mut self , source_id : u64 , target_id : u64 ) {
214+ if let Some ( alias) = self . type_variables . get ( & source_id) {
215+ _ = self . type_variables . insert ( target_id, alias. clone ( ) ) ;
214216 }
215217 }
216218
You can’t perform that action at this time.
0 commit comments