Skip to content

Commit

Permalink
use old name
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 12, 2024
1 parent 377aa3a commit df402d9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion vlib/v/ast/scope.v
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn (sc &Scope) show(depth int, max_depth int) string {
return out
}

pub fn (mut sc Scope) mark_used(varname string) bool {
pub fn (mut sc Scope) mark_var_as_used(varname string) bool {
mut obj := sc.find(varname) or { return false }
if mut obj is Var {
obj.is_used = true
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/parser/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ fn (mut p Parser) comptime_for() ast.ComptimeFor {
typ = p.parse_any_type(lang, false, true, false)
} else {
expr = p.ident(lang)
p.scope.mark_used((expr as ast.Ident).name)
p.scope.mark_var_as_used((expr as ast.Ident).name)
}
typ_pos = typ_pos.extend(p.prev_tok.pos())
p.check(.dot)
Expand Down Expand Up @@ -470,7 +470,7 @@ fn (mut p Parser) comptime_selector(left ast.Expr) ast.Expr {
if p.peek_tok.kind == .lpar {
method_pos := p.tok.pos()
method_name := p.check_name()
p.scope.mark_used(method_name)
p.scope.mark_var_as_used(method_name)
// `app.$action()` (`action` is a string)
p.check(.lpar)
args := p.call_args()
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/parser/expr.v
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
ident := p.ident(.v)
node = ident
if p.peek_tok.kind != .assign && (p.inside_if_cond || p.inside_match) {
p.scope.mark_used(ident.name)
p.scope.mark_var_as_used(ident.name)
}
p.add_defer_var(ident)
p.is_stmt_ident = is_stmt_ident
Expand Down Expand Up @@ -356,7 +356,7 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
} else {
p.check(.lpar)
pos := p.tok.pos()
mut is_known_var := p.scope.mark_used(p.tok.lit)
mut is_known_var := p.scope.mark_var_as_used(p.tok.lit)
|| p.table.global_scope.known_const(p.mod + '.' + p.tok.lit)
//|| p.table.known_fn(p.mod + '.' + p.tok.lit)
// assume `mod.` prefix leads to a type
Expand Down Expand Up @@ -524,7 +524,7 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
// variable name: type
ident := p.ident(.v)
node = ident
p.scope.mark_used(ident.name)
p.scope.mark_var_as_used(ident.name)
p.add_defer_var(ident)
p.is_stmt_ident = is_stmt_ident
} else if p.tok.kind != .eof && !(p.tok.kind == .rsbr && p.inside_asm) {
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/parser/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
} else if p.peek_tok.kind == .name {
return p.unexpected(got: 'name `${p.tok.lit}`')
} else if !p.inside_if_expr && !p.inside_match_body && !p.inside_or_expr
&& p.peek_tok.kind in [.rcbr, .eof] && !p.scope.mark_used(p.tok.lit) {
&& p.peek_tok.kind in [.rcbr, .eof] && !p.scope.mark_var_as_used(p.tok.lit) {
return p.error_with_pos('`${p.tok.lit}` evaluated but not used', p.tok.pos())
}
return p.parse_multi_expr(is_top_level)
Expand Down Expand Up @@ -2626,7 +2626,7 @@ fn (mut p Parser) name_expr() ast.Expr {
// get type position before moving to next
is_known_var := p.scope.known_var(p.tok.lit)
if is_known_var {
p.scope.mark_used(p.tok.lit)
p.scope.mark_var_as_used(p.tok.lit)
return p.ident(.v)
} else {
type_pos := p.tok.pos()
Expand Down Expand Up @@ -2748,7 +2748,7 @@ fn (mut p Parser) name_expr() ast.Expr {
known_var := if p.peek_tok.kind.is_assign() {
p.scope.known_var(p.tok.lit)
} else {
p.scope.mark_used(p.tok.lit)
p.scope.mark_var_as_used(p.tok.lit)
}
// Handle modules
mut is_mod_cast := false
Expand Down

0 comments on commit df402d9

Please sign in to comment.