alias referenced by another alias is not unused!

This commit is contained in:
Folkert 2020-11-09 22:22:00 +01:00
parent 0b19c594c5
commit 33f65caedd
2 changed files with 27 additions and 11 deletions

View file

@ -184,17 +184,11 @@ pub fn canonicalize_defs<'a>(
let mut can_ann =
canonicalize_annotation(env, &mut scope, &ann.value, ann.region, var_store);
// all referenced symbols in an alias must be symbols
output
.references
.referenced_aliases
.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());
// Record all the annotation's references in output.references.lookups
for symbol in can_ann.references {
output.references.lookups.insert(symbol);
output.references.referenced_aliases.insert(symbol);
}
let mut can_vars: Vec<Located<(Lowercase, Variable)>> =
Vec::with_capacity(vars.len());

View file

@ -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
"#
),
"",
)
}
}