File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -596,8 +596,14 @@ impl Environment<'_> {
596
596
// Check this in the hydrator, i.e. is it a created type
597
597
let v = self . new_unbound_var ( ) ;
598
598
let _ = ids. insert ( * id, v. clone ( ) ) ;
599
- let new_id = self . previous_uid ( ) ;
600
- self . names . map_new_variable ( * id, new_id) ;
599
+
600
+ // Preserve any user-provided name from the original generic variable
601
+ // for the new unbound variable. This ensures error messages and type
602
+ // displays continue to use meaningful names (e.g., "something") rather
603
+ // than auto-generated ones (e.g., "a", "b").
604
+ let v_id = self . previous_uid ( ) ;
605
+ self . names . reassign_type_variable_alias ( * id, v_id) ;
606
+
601
607
return v;
602
608
}
603
609
}
Original file line number Diff line number Diff line change @@ -181,9 +181,11 @@ impl Names {
181
181
_ = self . type_variables . insert ( id, local_alias. clone ( ) ) ;
182
182
}
183
183
184
- pub fn map_new_variable ( & mut self , old_id : u64 , new_id : u64 ) {
185
- if let Some ( alias) = self . type_variables . get ( & old_id) {
186
- _ = self . type_variables . insert ( new_id, alias. clone ( ) ) ;
184
+ /// Assigns `source_id` alias to `target_id`. This is useful when type variables are unified
185
+ /// and we need to preserve the original name for consistent error messages and type display.
186
+ pub fn reassign_type_variable_alias ( & mut self , source_id : u64 , target_id : u64 ) {
187
+ if let Some ( alias) = self . type_variables . get ( & source_id) {
188
+ _ = self . type_variables . insert ( target_id, alias. clone ( ) ) ;
187
189
}
188
190
}
189
191
You can’t perform that action at this time.
0 commit comments