mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
alias referenced by another alias is not unused!
This commit is contained in:
parent
0b19c594c5
commit
33f65caedd
2 changed files with 27 additions and 11 deletions
|
@ -184,17 +184,11 @@ pub fn canonicalize_defs<'a>(
|
||||||
let mut can_ann =
|
let mut can_ann =
|
||||||
canonicalize_annotation(env, &mut scope, &ann.value, ann.region, var_store);
|
canonicalize_annotation(env, &mut scope, &ann.value, ann.region, var_store);
|
||||||
|
|
||||||
// all referenced symbols in an alias must be symbols
|
// Record all the annotation's references in output.references.lookups
|
||||||
output
|
for symbol in can_ann.references {
|
||||||
.references
|
output.references.lookups.insert(symbol);
|
||||||
.referenced_aliases
|
output.references.referenced_aliases.insert(symbol);
|
||||||
.extend(can_ann.aliases.keys().copied());
|
}
|
||||||
|
|
||||||
// if an alias definition uses an alias, the used alias is referenced
|
|
||||||
output
|
|
||||||
.references
|
|
||||||
.lookups
|
|
||||||
.extend(can_ann.aliases.keys().copied());
|
|
||||||
|
|
||||||
let mut can_vars: Vec<Located<(Lowercase, Variable)>> =
|
let mut can_vars: Vec<Located<(Lowercase, Variable)>> =
|
||||||
Vec::with_capacity(vars.len());
|
Vec::with_capacity(vars.len());
|
||||||
|
|
|
@ -3880,4 +3880,26 @@ mod test_reporting {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn alias_using_alias() {
|
||||||
|
report_problem_as(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
# The color of a node. Leaves are considered Black.
|
||||||
|
NodeColor : [ Red, Black ]
|
||||||
|
|
||||||
|
Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ]
|
||||||
|
|
||||||
|
# Create an empty dictionary.
|
||||||
|
empty : Dict k v
|
||||||
|
empty =
|
||||||
|
Empty
|
||||||
|
|
||||||
|
empty
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue