Look up predecl only in the working set (#4592)

Previously, the parser tried to look up the predecl also in the
permanent state and if a definition with that name already existed, it
would try to update it, which is illegal.
This commit is contained in:
Jakub Žádník
2022-02-21 23:05:20 +02:00
committed by GitHub
parent 6d4784a7c1
commit 359bb6eebe
2 changed files with 12 additions and 2 deletions

View File

@ -999,6 +999,16 @@ impl<'a> StateWorkingSet<'a> {
self.delta.exit_scope();
}
pub fn find_predecl(&self, name: &[u8]) -> Option<DeclId> {
for scope in self.delta.scope.iter().rev() {
if let Some(decl_id) = scope.predecls.get(name) {
return Some(*decl_id);
}
}
None
}
pub fn find_decl(&self, name: &[u8]) -> Option<DeclId> {
let mut visibility: Visibility = Visibility::new();