Fix property wrongly considered as const if it is modified through an alias

Fixes #4241
This commit is contained in:
Olivier Goffart 2024-01-02 15:59:48 +01:00
parent a4f2b45d9a
commit 96324a8300
2 changed files with 69 additions and 6 deletions

View file

@ -83,13 +83,14 @@ impl NamedReference {
return false;
}
if check_binding {
if let Some(b) = e.bindings.get(self.name()) {
if !b.borrow().analysis.as_ref().map_or(false, |a| a.is_const) {
return false;
}
check_binding = false;
if let Some(b) = e.bindings.get(self.name()) {
if check_binding && !b.borrow().analysis.as_ref().map_or(false, |a| a.is_const) {
return false;
}
if !b.borrow().two_way_bindings.iter().all(|n| n.is_constant()) {
return false;
}
check_binding = false;
}
if let Some(decl) = e.property_declarations.get(self.name()) {
if let Some(alias) = &decl.is_alias {