mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
fixed bug in resolver
This commit is contained in:
parent
da6a820638
commit
76bf3a2a07
1 changed files with 6 additions and 6 deletions
|
|
@ -120,12 +120,6 @@ impl Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_var(&mut self, name: &str) -> ResolverResult<Expr> {
|
fn resolve_var(&mut self, name: &str) -> ResolverResult<Expr> {
|
||||||
if name == "this" {
|
|
||||||
return Err(ResolverError::ThisOutsideMethod);
|
|
||||||
} else if name == "super" {
|
|
||||||
return Err(ResolverError::SuperOutsideMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut level = 0;
|
let mut level = 0;
|
||||||
|
|
||||||
// resolve normal local variable
|
// resolve normal local variable
|
||||||
|
|
@ -161,6 +155,12 @@ impl Resolver {
|
||||||
return Ok(Expr::global_variable(name));
|
return Ok(Expr::global_variable(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if name == "this" {
|
||||||
|
return Err(ResolverError::ThisOutsideMethod);
|
||||||
|
} else if name == "super" {
|
||||||
|
return Err(ResolverError::SuperOutsideMethod);
|
||||||
|
}
|
||||||
|
|
||||||
let name = name.into();
|
let name = name.into();
|
||||||
|
|
||||||
Err(ResolverError::UnresolvableVariable { name })
|
Err(ResolverError::UnresolvableVariable { name })
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue