From f4cc3c19b2ca2c1a9ff19425fd30e498c2a38a02 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 22 Apr 2026 18:43:48 +0300 Subject: [PATCH] checker: fix underline by 2 chars --- vlib/v/checker/checker.v | 14 +++++++------- vlib/v/checker/tests/array_index.out | 4 ++-- vlib/v/checker/tests/index_expr.out | 12 ++++++------ .../tests/int_ptr_array_index_decl_assign_err.out | 4 ++-- vlib/v/checker/tests/int_ptr_array_index_err.out | 4 ++-- vlib/v/checker/tests/option_fn_err.out | 4 ++-- vlib/v/checker/tests/string_index_non_int_err.out | 12 ++++++------ 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 086ef66bb..221802795 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -7659,8 +7659,8 @@ fn (mut c Checker) type_error_for_operator(op_label string, types_label string, pos) } -fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_type ast.Type, pos token.Pos, - range_index bool, is_gated bool) { +fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_type ast.Type, range_index bool, + is_gated bool) { if typ_sym.kind in [.array, .array_fixed, .string] { index_type_sym := c.table.sym(index_type) if !(index_type.is_int() || index_type_sym.kind == .enum @@ -7672,7 +7672,7 @@ fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_ty } else { 'non-integer index `${c.table.type_to_str(index_type)}` (array type `${typ_sym.name}`)' } - c.error('${type_str}', pos) + c.error('${type_str}', index.pos()) } if index is ast.IntegerLiteral && !is_gated { if index.val[0] == `-` { @@ -7691,7 +7691,7 @@ fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_ty } else { '(array type `${typ_sym.name}`)' } - c.error('cannot use Option or Result as index ${type_str}', pos) + c.error('cannot use Option or Result as index ${type_str}', index.pos()) } } } @@ -7870,11 +7870,11 @@ fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type { if mut node.index is ast.RangeExpr { // [1..2] if node.index.has_low { index_type := c.expr(mut node.index.low) - c.check_index(typ_sym, node.index.low, index_type, node.pos, true, node.is_gated) + c.check_index(typ_sym, node.index.low, index_type, true, node.is_gated) } if node.index.has_high { index_type := c.expr(mut node.index.high) - c.check_index(typ_sym, node.index.high, index_type, node.pos, true, node.is_gated) + c.check_index(typ_sym, node.index.high, index_type, true, node.is_gated) } // array[1..2] => array // fixed_array[1..2] => array @@ -7924,7 +7924,7 @@ fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type { c.error('`#[]` negative indexing is only supported for arrays, fixed arrays, and strings', node.pos) } - c.check_index(typ_sym, node.index, index_type, node.pos, false, node.is_gated) + c.check_index(typ_sym, node.index, index_type, false, node.is_gated) } value_type := c.table.value_type(typ) if value_type != ast.void_type { diff --git a/vlib/v/checker/tests/array_index.out b/vlib/v/checker/tests/array_index.out index 7bfaf7ab6..8160fb69a 100644 --- a/vlib/v/checker/tests/array_index.out +++ b/vlib/v/checker/tests/array_index.out @@ -1,8 +1,8 @@ -vlib/v/checker/tests/array_index.vv:3:7: error: non-integer index `float literal` (array type `[2]int`) +vlib/v/checker/tests/array_index.vv:3:8: error: non-integer index `float literal` (array type `[2]int`) 1 | fn fixed() { 2 | a := [1, 2]! 3 | _ = a[0.2] - | ~~~~~ + | ~~~ 4 | _ = a[1] // OK 5 | _ = a[-1] vlib/v/checker/tests/array_index.vv:5:8: error: negative index `-1` diff --git a/vlib/v/checker/tests/index_expr.out b/vlib/v/checker/tests/index_expr.out index 7e6553595..a0e464c7f 100644 --- a/vlib/v/checker/tests/index_expr.out +++ b/vlib/v/checker/tests/index_expr.out @@ -5,11 +5,11 @@ vlib/v/checker/tests/index_expr.vv:3:7: error: type `int` does not support index | ~~~ 4 | 5 | a := [2] -vlib/v/checker/tests/index_expr.vv:6:7: error: non-integer index `[]int` (array type `[]int`) +vlib/v/checker/tests/index_expr.vv:6:8: error: non-integer index `[]int` (array type `[]int`) 4 | 5 | a := [2] 6 | _ = a[a] - | ~~~ + | ^ 7 | _ = a[-1] 8 | } vlib/v/checker/tests/index_expr.vv:7:8: error: negative index `-1` @@ -33,18 +33,18 @@ vlib/v/checker/tests/index_expr.vv:13:7: error: type `int` does not support inde | ~~~~~ 14 | 15 | a := [2] -vlib/v/checker/tests/index_expr.vv:16:7: error: non-integer index `[]int` (array type `[]int`) +vlib/v/checker/tests/index_expr.vv:16:8: error: non-integer index `[]int` (array type `[]int`) 14 | 15 | a := [2] 16 | _ = a[a..] - | ~~~~~ + | ^ 17 | _ = a[..a] 18 | _ = a[-1..] -vlib/v/checker/tests/index_expr.vv:17:7: error: non-integer index `[]int` (array type `[]int`) +vlib/v/checker/tests/index_expr.vv:17:10: error: non-integer index `[]int` (array type `[]int`) 15 | a := [2] 16 | _ = a[a..] 17 | _ = a[..a] - | ~~~~~ + | ^ 18 | _ = a[-1..] 19 | _ = a[..-1] vlib/v/checker/tests/index_expr.vv:18:8: error: negative index `-1` diff --git a/vlib/v/checker/tests/int_ptr_array_index_decl_assign_err.out b/vlib/v/checker/tests/int_ptr_array_index_decl_assign_err.out index c3270bad9..411eedb8e 100644 --- a/vlib/v/checker/tests/int_ptr_array_index_decl_assign_err.out +++ b/vlib/v/checker/tests/int_ptr_array_index_decl_assign_err.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/int_ptr_array_index_decl_assign_err.vv:3:14: error: non-integer index `&int` (array type `[]u8`) +vlib/v/checker/tests/int_ptr_array_index_decl_assign_err.vv:3:15: error: non-integer index `&int` (array type `[]u8`) 1 | pub fn read_int(bytes []u8, mut offset &int) int { 2 | offset_d := offset 3 | return bytes[offset_d] - | ~~~~~~~~ + | ~~~~~~~~ 4 | } diff --git a/vlib/v/checker/tests/int_ptr_array_index_err.out b/vlib/v/checker/tests/int_ptr_array_index_err.out index f42a700e0..029c899ad 100644 --- a/vlib/v/checker/tests/int_ptr_array_index_err.out +++ b/vlib/v/checker/tests/int_ptr_array_index_err.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/int_ptr_array_index_err.vv:5:14: error: non-integer index `&int` (array type `[]u8`) +vlib/v/checker/tests/int_ptr_array_index_err.vv:5:15: error: non-integer index `&int` (array type `[]u8`) 3 | offset += 4 4 | } 5 | return bytes[offset] - | ~~~~~~~~ + | ~~~~~~ 6 | } diff --git a/vlib/v/checker/tests/option_fn_err.out b/vlib/v/checker/tests/option_fn_err.out index cd4fdbad2..eaab01395 100644 --- a/vlib/v/checker/tests/option_fn_err.out +++ b/vlib/v/checker/tests/option_fn_err.out @@ -68,11 +68,11 @@ vlib/v/checker/tests/option_fn_err.vv:56:20: error: cannot use unwrapped Option | ~~~~~~ 57 | // index 58 | println(arr[bar(0)]) -vlib/v/checker/tests/option_fn_err.vv:58:13: error: cannot use Option or Result as index (array type `[]int`) +vlib/v/checker/tests/option_fn_err.vv:58:14: error: cannot use Option or Result as index (array type `[]int`) 56 | _ := [1]int{init: bar(0)} 57 | // index 58 | println(arr[bar(0)]) - | ~~~~~~~~ + | ~~~~~~ 59 | // array builtin methods 60 | arr.insert(0, bar(0)) vlib/v/checker/tests/option_fn_err.vv:60:16: error: cannot use `?int` as `voidptr`, it must be unwrapped first in argument 2 to `[]int.insert` diff --git a/vlib/v/checker/tests/string_index_non_int_err.out b/vlib/v/checker/tests/string_index_non_int_err.out index c62d8163a..d6bf212f9 100644 --- a/vlib/v/checker/tests/string_index_non_int_err.out +++ b/vlib/v/checker/tests/string_index_non_int_err.out @@ -1,20 +1,20 @@ -vlib/v/checker/tests/string_index_non_int_err.vv:3:11: error: non-integer string index `string` +vlib/v/checker/tests/string_index_non_int_err.vv:3:12: error: non-integer string index `string` 1 | fn main() { 2 | v := 'foo' 3 | println(v['f']) - | ~~~~~ + | ~~~ 4 | println(v[true]) 5 | println(v[[23]]) -vlib/v/checker/tests/string_index_non_int_err.vv:4:11: error: non-integer string index `bool` +vlib/v/checker/tests/string_index_non_int_err.vv:4:12: error: non-integer string index `bool` 2 | v := 'foo' 3 | println(v['f']) 4 | println(v[true]) - | ~~~~~~ + | ~~~~ 5 | println(v[[23]]) 6 | } -vlib/v/checker/tests/string_index_non_int_err.vv:5:11: error: non-integer string index `[]int` +vlib/v/checker/tests/string_index_non_int_err.vv:5:12: error: non-integer string index `[]int` 3 | println(v['f']) 4 | println(v[true]) 5 | println(v[[23]]) - | ~~~~~~ + | ~~~~ 6 | } -- 2.39.5