diff --git a/vlib/v/ast/scope.v b/vlib/v/ast/scope.v index 329ee554f8..c846debc37 100644 --- a/vlib/v/ast/scope.v +++ b/vlib/v/ast/scope.v @@ -21,23 +21,13 @@ pub fn new_scope(parent &Scope, start_pos int) &Scope { } } -pub struct ScopeVar { -pub: - scope &Scope - var Var -} - -// pub fn (s &Scope) find_scope_and_var(name string) ?(&Scope,Var) { -pub fn (s &Scope) find_scope_and_var(name string) ?ScopeVar { +pub fn (s &Scope) find_scope_and_var(name string) ?(&Scope,Var) { if name in s.vars { - // return s,s.vars[name] - return ScopeVar{ - s,s.vars[name]} + return s,s.vars[name] } for sc := s; !isnil(sc.parent); sc = sc.parent { if name in sc.vars { - return ScopeVar{ - sc,sc.vars[name]} + return sc,sc.vars[name] } } return none diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index be99e20a73..8e822d78f3 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -809,16 +809,11 @@ pub fn (c mut Checker) ident(ident mut ast.Ident) table.Type { } start_scope := c.file.scope.innermost(ident.pos.pos) mut found := true - mut var_scope := &ast.Scope(0) - mut var := ast.Var{} - // var_scope,var = start_scope.find_scope_and_var(ident.name) or { - mr := start_scope.find_scope_and_var(ident.name) or { + var_scope,var := start_scope.find_scope_and_var(ident.name) or { found = false c.error('not found: $ident.name - POS: $ident.pos.pos', ident.pos) panic('') } - var_scope = mr.scope - var = mr.var if found { // update the variable // we need to do this here instead of var_decl since some