mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Print able type variables correctly
This commit is contained in:
parent
154b17d9f0
commit
b3845c21bd
3 changed files with 35 additions and 8 deletions
|
@ -116,7 +116,7 @@ fn find_names_needed(
|
|||
}
|
||||
|
||||
match &subs.get_content_without_compacting(variable).clone() {
|
||||
RecursionVar { opt_name: None, .. } | FlexVar(None) | FlexAbleVar(None, _) => {
|
||||
RecursionVar { opt_name: None, .. } | FlexVar(None) => {
|
||||
let root = subs.get_root_key_without_compacting(variable);
|
||||
|
||||
// If this var is *not* its own root, then the
|
||||
|
@ -135,6 +135,15 @@ fn find_names_needed(
|
|||
}
|
||||
}
|
||||
}
|
||||
FlexAbleVar(None, _) => {
|
||||
let root = subs.get_root_key_without_compacting(variable);
|
||||
if !root_appearances.contains_key(&root) {
|
||||
roots.push(root);
|
||||
}
|
||||
// Able vars are always printed at least twice (in the signature, and in the "has"
|
||||
// clause set).
|
||||
root_appearances.insert(root, Appearances::Multiple);
|
||||
}
|
||||
RecursionVar {
|
||||
opt_name: Some(name_index),
|
||||
..
|
||||
|
@ -271,6 +280,11 @@ fn set_root_name(root: Variable, name: Lowercase, subs: &mut Subs) {
|
|||
let content = FlexVar(Some(name_index));
|
||||
subs.set_content(root, content);
|
||||
}
|
||||
&FlexAbleVar(None, ability) => {
|
||||
let name_index = SubsIndex::push_new(&mut subs.field_names, name);
|
||||
let content = FlexAbleVar(Some(name_index), ability);
|
||||
subs.set_content(root, content);
|
||||
}
|
||||
RecursionVar {
|
||||
opt_name: None,
|
||||
structure,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue