mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
stop scope diffing in when canonicalization
This commit is contained in:
parent
984ef53e75
commit
2d0a9c8531
3 changed files with 17 additions and 24 deletions
|
@ -1099,23 +1099,17 @@ fn canonicalize_when_branch<'a>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now that we've collected all the references for this branch, check to see if
|
|
||||||
// any of the new idents it defined were unused. If any were, report it.
|
|
||||||
for (symbol, region) in scope.symbols() {
|
|
||||||
let symbol = *symbol;
|
|
||||||
|
|
||||||
if !output.references.has_type_or_value_lookup(symbol)
|
|
||||||
&& !branch_output.references.has_type_or_value_lookup(symbol)
|
|
||||||
&& !original_scope.contains_symbol(symbol)
|
|
||||||
&& !scope.abilities_store.is_specialization_name(symbol)
|
|
||||||
{
|
|
||||||
env.problem(Problem::UnusedDef(symbol, *region));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let references = branch_output.references.clone();
|
let references = branch_output.references.clone();
|
||||||
output.union(branch_output);
|
output.union(branch_output);
|
||||||
|
|
||||||
|
// Now that we've collected all the references for this branch, check to see if
|
||||||
|
// any of the new idents it defined were unused. If any were, report it.
|
||||||
|
for (symbol, region) in bindings_from_patterns(patterns.iter()) {
|
||||||
|
if !output.references.has_value_lookup(symbol) {
|
||||||
|
env.problem(Problem::UnusedDef(symbol, region));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
WhenBranch {
|
WhenBranch {
|
||||||
patterns,
|
patterns,
|
||||||
|
|
|
@ -687,12 +687,15 @@ fn add_bindings_from_patterns(
|
||||||
add_bindings_from_patterns(&loc_arg.region, &loc_arg.value, answer);
|
add_bindings_from_patterns(&loc_arg.region, &loc_arg.value, answer);
|
||||||
}
|
}
|
||||||
RecordDestructure { destructs, .. } => {
|
RecordDestructure { destructs, .. } => {
|
||||||
for Loc {
|
for loc_destruct in destructs {
|
||||||
region,
|
match loc_destruct.value.typ {
|
||||||
value: RecordDestruct { symbol, .. },
|
DestructType::Required | DestructType::Optional(_, _) => {
|
||||||
} in destructs
|
answer.push((loc_destruct.value.symbol, loc_destruct.region));
|
||||||
{
|
}
|
||||||
answer.push((*symbol, *region));
|
DestructType::Guard(_, _) => {
|
||||||
|
// a guard does not introduce the symbol
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NumLiteral(..)
|
NumLiteral(..)
|
||||||
|
|
|
@ -104,10 +104,6 @@ impl Scope {
|
||||||
self.idents.contains_key(ident)
|
self.idents.contains_key(ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contains_symbol(&self, symbol: Symbol) -> bool {
|
|
||||||
self.symbols.contains_key(&symbol)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn num_idents(&self) -> usize {
|
pub fn num_idents(&self) -> usize {
|
||||||
self.idents.len()
|
self.idents.len()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue