From df402d9e9699ab85c06d533a9b3e381276cf7584 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Tue, 12 Nov 2024 11:42:47 -0300 Subject: [PATCH] use old name --- vlib/v/ast/scope.v | 2 +- vlib/v/parser/comptime.v | 4 ++-- vlib/v/parser/expr.v | 6 +++--- vlib/v/parser/parser.v | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vlib/v/ast/scope.v b/vlib/v/ast/scope.v index 8246855345fbc4..87604f1e8dedfc 100644 --- a/vlib/v/ast/scope.v +++ b/vlib/v/ast/scope.v @@ -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 diff --git a/vlib/v/parser/comptime.v b/vlib/v/parser/comptime.v index ce0178292f5274..9f14a749d63b6b 100644 --- a/vlib/v/parser/comptime.v +++ b/vlib/v/parser/comptime.v @@ -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) @@ -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() diff --git a/vlib/v/parser/expr.v b/vlib/v/parser/expr.v index 9720ccf01563db..07b1dc1431c595 100644 --- a/vlib/v/parser/expr.v +++ b/vlib/v/parser/expr.v @@ -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 @@ -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 @@ -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) { diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index d09c26d07ca689..fac47ae3e6de37 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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) @@ -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() @@ -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