Fixup annotated bindings

This commit is contained in:
Marcus Klaas de Vries 2019-01-17 13:40:45 +01:00 committed by Aleksey Kladov
parent d48d5b8b6c
commit 44e9a9605b
6 changed files with 54 additions and 30 deletions

View file

@ -88,10 +88,17 @@ impl FnScopes {
fn add_bindings(&mut self, body: &Body, scope: ScopeId, pat: PatId) {
match &body[pat] {
Pat::Bind { name, .. } => self.scopes[scope].entries.push(ScopeEntry {
name: name.clone(),
pat,
}),
Pat::Bind { name, .. } => {
// bind can have a subpattern, but it's actually not allowed
// to bind to things in there
let entry = ScopeEntry {
name: name.clone(),
pat,
};
self.scopes[scope].entries.push(entry)
}
// FIXME: isn't every call to add_binding starting an entirely new
// tree walk!?
p => p.walk_child_pats(|pat| self.add_bindings(body, scope, pat)),
}
}