diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index a48dfbc335..5a08f46559 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -3,7 +3,6 @@ module checker import os -import time import v.ast import v.vmod import v.token @@ -46,15 +45,21 @@ pub struct Checker { pub mut: pref &pref.Preferences = unsafe { nil } // Preferences shared from V struct // - table &ast.Table = unsafe { nil } - file &ast.File = unsafe { nil } - nr_errors int - nr_warnings int - nr_notices int - errors []errors.Error - warnings []errors.Warning - notices []errors.Notice - error_lines []int // to avoid printing multiple errors for the same line + table &ast.Table = unsafe { nil } + file &ast.File = unsafe { nil } + // + nr_errors int + nr_warnings int + nr_notices int + errors []errors.Error + warnings []errors.Warning + notices []errors.Notice + error_lines map[string]bool // dedup errors + warning_lines map[string]bool // dedup warns + notice_lines map[string]bool // dedup notices + error_details []string + should_abort bool // when too many errors/warnings/notices are accumulated, .should_abort becomes true. It is checked in statement/expression loops, so the checker can return early, instead of wasting time. + // expected_type ast.Type expected_or_type ast.Type // fn() or { 'this type' } eg. string. expected or block type expected_expr_type ast.Type // if/match is_expr: expected_type @@ -66,7 +71,6 @@ pub mut: locked_names []string // vars that are currently locked rlocked_names []string // vars that are currently read-locked in_for_count int // if checker is currently in a for loop - should_abort bool // when too many errors/warnings/notices are accumulated, .should_abort becomes true. It is checked in statement/expression loops, so the checker can return early, instead of wasting time. returns bool scope_returns bool is_builtin_mod bool // true inside the 'builtin', 'os' or 'strconv' modules; TODO: remove the need for special casing this @@ -100,7 +104,6 @@ mut: ensure_generic_type_level int // to avoid infinite recursion segfaults in ensure_generic_type_specify_type_names cur_orm_ts ast.TypeSymbol cur_anon_fn &ast.AnonFn = unsafe { nil } - error_details []string vmod_file_content string // needed for @VMOD_FILE, contents of the file, *NOT its path** loop_label string // set when inside a labelled for loop vweb_gen_types []ast.Type // vweb route checks @@ -176,6 +179,7 @@ fn (mut c Checker) reset_checker_state_at_start_of_new_file() { c.inside_casting_to_str = false c.inside_decl_rhs = false c.inside_if_guard = false + c.error_details.clear() } pub fn (mut c Checker) check(mut ast_file ast.File) { @@ -4531,47 +4535,6 @@ fn (mut c Checker) check_dup_keys(node &ast.MapInit, i int) { } } -// call this *before* calling error or warn -fn (mut c Checker) add_error_detail(s string) { - c.error_details << s -} - -fn (mut c Checker) add_error_detail_with_pos(msg string, pos token.Pos) { - c.add_error_detail(util.formatted_error('details:', msg, c.file.path, pos)) -} - -fn (mut c Checker) add_instruction_for_option_type() { - c.add_error_detail_with_pos('prepend ? before the declaration of the return type of `${c.table.cur_fn.name}`', - c.table.cur_fn.return_type_pos) -} - -fn (mut c Checker) add_instruction_for_result_type() { - c.add_error_detail_with_pos('prepend ! before the declaration of the return type of `${c.table.cur_fn.name}`', - c.table.cur_fn.return_type_pos) -} - -fn (mut c Checker) warn(s string, pos token.Pos) { - allow_warnings := !(c.pref.is_prod || c.pref.warns_are_errors) // allow warnings only in dev builds - c.warn_or_error(s, pos, allow_warnings) -} - -fn (mut c Checker) error(message string, pos token.Pos) { - $if checker_exit_on_first_error ? { - eprintln('\n\n>> checker error: ${message}, pos: ${pos}') - print_backtrace() - exit(1) - } - if (c.pref.translated || c.file.is_translated) && message.starts_with('mismatched types') { - // TODO move this - return - } - if c.pref.is_verbose { - print_backtrace() - } - msg := message.replace('`Array_', '`[]') - c.warn_or_error(msg, pos, false) -} - fn (c &Checker) check_struct_signature_init_fields(from ast.Struct, to ast.Struct, node ast.StructInit) bool { if node.init_fields.len == 0 { return from.fields.len == to.fields.len @@ -4617,96 +4580,6 @@ fn (c &Checker) check_struct_signature(from ast.Struct, to ast.Struct) bool { return true } -fn (mut c Checker) note(message string, pos token.Pos) { - if c.pref.message_limit >= 0 && c.nr_notices >= c.pref.message_limit { - c.should_abort = true - return - } - if c.is_generated { - return - } - if c.pref.notes_are_errors { - c.error(message, pos) - } - mut details := '' - if c.error_details.len > 0 { - details = c.error_details.join('\n') - c.error_details = [] - } - wrn := errors.Notice{ - reporter: errors.Reporter.checker - pos: pos - file_path: c.file.path - message: message - details: details - } - c.file.notices << wrn - c.notices << wrn - c.nr_notices++ -} - -fn (mut c Checker) warn_or_error(message string, pos token.Pos, warn bool) { - // add backtrace to issue struct, how? - // if c.pref.is_verbose { - // print_backtrace() - // } - mut details := '' - if c.error_details.len > 0 { - details = c.error_details.join('\n') - c.error_details = [] - } - if warn && !c.pref.skip_warnings { - c.nr_warnings++ - if c.pref.message_limit >= 0 && c.nr_warnings >= c.pref.message_limit { - c.should_abort = true - return - } - wrn := errors.Warning{ - reporter: errors.Reporter.checker - pos: pos - file_path: c.file.path - message: message - details: details - } - c.file.warnings << wrn - c.warnings << wrn - return - } - if !warn { - if c.pref.fatal_errors { - util.show_compiler_message('error:', errors.CompilerMessage{ - pos: pos - file_path: c.file.path - message: message - details: details - }) - exit(1) - } - c.nr_errors++ - if c.pref.message_limit >= 0 && c.errors.len >= c.pref.message_limit { - c.should_abort = true - return - } - if pos.line_nr !in c.error_lines { - err := errors.Error{ - reporter: errors.Reporter.checker - pos: pos - file_path: c.file.path - message: message - details: details - } - c.file.errors << err - c.errors << err - c.error_lines << pos.line_nr - } - } -} - -// for debugging only -fn (c &Checker) fileis(s string) bool { - return c.file.path.contains(s) -} - fn (mut c Checker) fetch_field_name(field ast.StructField) string { mut name := field.name for attr in field.attrs { @@ -4722,12 +4595,6 @@ fn (mut c Checker) fetch_field_name(field ast.StructField) string { return name } -fn (mut c Checker) trace[T](fbase string, x &T) { - if c.file.path_base == fbase { - println('> c.trace | ${fbase:-10s} | ${x}') - } -} - fn (mut c Checker) ensure_generic_type_specify_type_names(typ ast.Type, pos token.Pos) bool { if typ == 0 { c.error('unknown type', pos) @@ -5013,45 +4880,6 @@ fn (mut c Checker) check_unused_labels() { } } -fn (mut c Checker) deprecate(kind string, name string, attrs []ast.Attr, pos token.Pos) { - mut deprecation_message := '' - now := time.now() - mut after_time := now - for attr in attrs { - if attr.name == 'deprecated' && attr.arg != '' { - deprecation_message = attr.arg - } - if attr.name == 'deprecated_after' && attr.arg != '' { - after_time = time.parse_iso8601(attr.arg) or { - c.error('invalid time format', attr.pos) - now - } - } - } - start_message := '${kind} `${name}`' - error_time := after_time.add_days(180) - if error_time < now { - c.error(semicolonize('${start_message} has been deprecated since ${after_time.ymmdd()}', - deprecation_message), pos) - } else if after_time < now { - c.warn(semicolonize('${start_message} has been deprecated since ${after_time.ymmdd()}, it will be an error after ${error_time.ymmdd()}', - deprecation_message), pos) - } else if after_time == now { - c.warn(semicolonize('${start_message} has been deprecated', deprecation_message), - pos) - } else { - c.note(semicolonize('${start_message} will be deprecated after ${after_time.ymmdd()}, and will become an error after ${error_time.ymmdd()}', - deprecation_message), pos) - } -} - -fn semicolonize(main string, details string) string { - if details == '' { - return main - } - return '${main}; ${details}' -} - fn (mut c Checker) deprecate_old_isreftype_and_sizeof_of_a_guessed_type(is_guessed_type bool, typ ast.Type, pos token.Pos, label string) { if is_guessed_type { styp := c.table.type_to_str(typ) diff --git a/vlib/v/checker/errors.v b/vlib/v/checker/errors.v new file mode 100644 index 0000000000..3e0e7a3e17 --- /dev/null +++ b/vlib/v/checker/errors.v @@ -0,0 +1,195 @@ +// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license that can be found in the LICENSE file. +module checker + +import time +import v.ast +import v.token +import v.errors +import v.util + +// call this *before* calling error or warn +fn (mut c Checker) add_error_detail(s string) { + c.error_details << s +} + +fn (mut c Checker) add_error_detail_with_pos(msg string, pos token.Pos) { + c.add_error_detail(util.formatted_error('details:', msg, c.file.path, pos)) +} + +fn (mut c Checker) add_instruction_for_option_type() { + c.add_error_detail_with_pos('prepend ? before the declaration of the return type of `${c.table.cur_fn.name}`', + c.table.cur_fn.return_type_pos) +} + +fn (mut c Checker) add_instruction_for_result_type() { + c.add_error_detail_with_pos('prepend ! before the declaration of the return type of `${c.table.cur_fn.name}`', + c.table.cur_fn.return_type_pos) +} + +fn (mut c Checker) warn(s string, pos token.Pos) { + allow_warnings := !(c.pref.is_prod || c.pref.warns_are_errors) // allow warnings only in dev builds + c.warn_or_error(s, pos, allow_warnings) +} + +fn (mut c Checker) error(message string, pos token.Pos) { + if (c.pref.translated || c.file.is_translated) && message.starts_with('mismatched types') { + // TODO move this + return + } + msg := message.replace('`Array_', '`[]') + c.warn_or_error(msg, pos, false) +} + +fn (mut c Checker) note(message string, pos token.Pos) { + if c.pref.message_limit >= 0 && c.nr_notices >= c.pref.message_limit { + c.should_abort = true + return + } + if c.is_generated { + return + } + if c.pref.notes_are_errors { + c.error(message, pos) + } + mut details := '' + if c.error_details.len > 0 { + details = c.error_details.join('\n') + c.error_details = [] + } + // deduplicate notices for the same line + kpos := '${c.file.path}:${pos.line_nr}:${message}' + if kpos !in c.notice_lines { + c.notice_lines[kpos] = true + note := errors.Notice{ + reporter: errors.Reporter.checker + pos: pos + file_path: c.file.path + message: message + details: details + } + c.file.notices << note + c.notices << note + c.nr_notices++ + } +} + +fn (mut c Checker) warn_or_error(message string, pos token.Pos, warn bool) { + if !warn { + $if checker_exit_on_first_error ? { + eprintln('\n\n>> checker error: ${message}, pos: ${pos}') + print_backtrace() + exit(1) + } + if c.pref.is_verbose { + print_backtrace() + } + } + mut details := '' + if c.error_details.len > 0 { + details = c.error_details.join('\n') + c.error_details = [] + } + if warn && !c.pref.skip_warnings { + c.nr_warnings++ + if c.pref.message_limit >= 0 && c.nr_warnings >= c.pref.message_limit { + c.should_abort = true + return + } + // deduplicate warnings for the same line + kpos := '${c.file.path}:${pos.line_nr}:${message}' + if kpos !in c.warning_lines { + c.warning_lines[kpos] = true + wrn := errors.Warning{ + reporter: errors.Reporter.checker + pos: pos + file_path: c.file.path + message: message + details: details + } + c.file.warnings << wrn + c.warnings << wrn + } + return + } + if !warn { + if c.pref.fatal_errors { + util.show_compiler_message('error:', errors.CompilerMessage{ + pos: pos + file_path: c.file.path + message: message + details: details + }) + exit(1) + } + c.nr_errors++ + if c.pref.message_limit >= 0 && c.errors.len >= c.pref.message_limit { + c.should_abort = true + return + } + // deduplicate errors for the same line + kpos := '${c.file.path}:${pos.line_nr}:${message}' + if kpos !in c.error_lines { + c.error_lines[kpos] = true + err := errors.Error{ + reporter: errors.Reporter.checker + pos: pos + file_path: c.file.path + message: message + details: details + } + c.file.errors << err + c.errors << err + } + } +} + +// for debugging only +fn (c &Checker) fileis(s string) bool { + return c.file.path.contains(s) +} + +fn (mut c Checker) trace[T](fbase string, x &T) { + if c.file.path_base == fbase { + println('> c.trace | ${fbase:-10s} | ${x}') + } +} + +fn (mut c Checker) deprecate(kind string, name string, attrs []ast.Attr, pos token.Pos) { + mut deprecation_message := '' + now := time.now() + mut after_time := now + for attr in attrs { + if attr.name == 'deprecated' && attr.arg != '' { + deprecation_message = attr.arg + } + if attr.name == 'deprecated_after' && attr.arg != '' { + after_time = time.parse_iso8601(attr.arg) or { + c.error('invalid time format', attr.pos) + now + } + } + } + start_message := '${kind} `${name}`' + error_time := after_time.add_days(180) + if error_time < now { + c.error(semicolonize('${start_message} has been deprecated since ${after_time.ymmdd()}', + deprecation_message), pos) + } else if after_time < now { + c.warn(semicolonize('${start_message} has been deprecated since ${after_time.ymmdd()}, it will be an error after ${error_time.ymmdd()}', + deprecation_message), pos) + } else if after_time == now { + c.warn(semicolonize('${start_message} has been deprecated', deprecation_message), + pos) + } else { + c.note(semicolonize('${start_message} will be deprecated after ${after_time.ymmdd()}, and will become an error after ${error_time.ymmdd()}', + deprecation_message), pos) + } +} + +fn semicolonize(main string, details string) string { + if details == '' { + return main + } + return '${main}; ${details}' +} diff --git a/vlib/v/checker/tests/add_op_wrong_type_err.out b/vlib/v/checker/tests/add_op_wrong_type_err.out index c1c8699172..123ddc36e3 100644 --- a/vlib/v/checker/tests/add_op_wrong_type_err.out +++ b/vlib/v/checker/tests/add_op_wrong_type_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/add_op_wrong_type_err.vv:3:13: error: mismatched types `Aaa | ~~~~~~~~~~ 4 | println(10 + Aaa{}) 5 | println([1,2,3] + 10) +vlib/v/checker/tests/add_op_wrong_type_err.vv:3:13: error: infix expr: cannot use `int literal` (right expression) as `Aaa` + 1 | struct Aaa{} + 2 | fn main() { + 3 | println(Aaa{} + 10) + | ~~~~~~~~~~ + 4 | println(10 + Aaa{}) + 5 | println([1,2,3] + 10) vlib/v/checker/tests/add_op_wrong_type_err.vv:4:13: error: mismatched types `int literal` and `Aaa` 2 | fn main() { 3 | println(Aaa{} + 10) @@ -12,6 +19,13 @@ vlib/v/checker/tests/add_op_wrong_type_err.vv:4:13: error: mismatched types `int | ~~~~~~~~~~ 5 | println([1,2,3] + 10) 6 | println(10 + [1,2,3]) +vlib/v/checker/tests/add_op_wrong_type_err.vv:4:13: error: infix expr: cannot use `Aaa` (right expression) as `int literal` + 2 | fn main() { + 3 | println(Aaa{} + 10) + 4 | println(10 + Aaa{}) + | ~~~~~~~~~~ + 5 | println([1,2,3] + 10) + 6 | println(10 + [1,2,3]) vlib/v/checker/tests/add_op_wrong_type_err.vv:5:13: error: mismatched types `[]int` and `int literal` 3 | println(Aaa{} + 10) 4 | println(10 + Aaa{}) @@ -19,6 +33,13 @@ vlib/v/checker/tests/add_op_wrong_type_err.vv:5:13: error: mismatched types `[]i | ~~~~~~~~~~~~ 6 | println(10 + [1,2,3]) 7 | a := map[string]int +vlib/v/checker/tests/add_op_wrong_type_err.vv:5:13: error: infix expr: cannot use `int literal` (right expression) as `[]int` + 3 | println(Aaa{} + 10) + 4 | println(10 + Aaa{}) + 5 | println([1,2,3] + 10) + | ~~~~~~~~~~~~ + 6 | println(10 + [1,2,3]) + 7 | a := map[string]int vlib/v/checker/tests/add_op_wrong_type_err.vv:6:13: error: mismatched types `int literal` and `[]int` 4 | println(10 + Aaa{}) 5 | println([1,2,3] + 10) @@ -26,6 +47,13 @@ vlib/v/checker/tests/add_op_wrong_type_err.vv:6:13: error: mismatched types `int | ~~~~~~~~~~~~ 7 | a := map[string]int 8 | println(a + 10) +vlib/v/checker/tests/add_op_wrong_type_err.vv:6:13: error: infix expr: cannot use `[]int` (right expression) as `int literal` + 4 | println(10 + Aaa{}) + 5 | println([1,2,3] + 10) + 6 | println(10 + [1,2,3]) + | ~~~~~~~~~~~~ + 7 | a := map[string]int + 8 | println(a + 10) vlib/v/checker/tests/add_op_wrong_type_err.vv:8:13: error: mismatched types `map[string]int` and `int literal` 6 | println(10 + [1,2,3]) 7 | a := map[string]int @@ -33,10 +61,22 @@ vlib/v/checker/tests/add_op_wrong_type_err.vv:8:13: error: mismatched types `map | ~~~~~~ 9 | println(10 + a) 10 | } +vlib/v/checker/tests/add_op_wrong_type_err.vv:8:13: error: infix expr: cannot use `int literal` (right expression) as `map[string]int` + 6 | println(10 + [1,2,3]) + 7 | a := map[string]int + 8 | println(a + 10) + | ~~~~~~ + 9 | println(10 + a) + 10 | } vlib/v/checker/tests/add_op_wrong_type_err.vv:9:13: error: mismatched types `int literal` and `map[string]int` 7 | a := map[string]int 8 | println(a + 10) 9 | println(10 + a) | ~~~~~~ 10 | } - +vlib/v/checker/tests/add_op_wrong_type_err.vv:9:13: error: infix expr: cannot use `map[string]int` (right expression) as `int literal` + 7 | a := map[string]int + 8 | println(a + 10) + 9 | println(10 + a) + | ~~~~~~ + 10 | } diff --git a/vlib/v/checker/tests/ambiguous_field_method_err.out b/vlib/v/checker/tests/ambiguous_field_method_err.out index 31a7360d5e..9360bb6b90 100644 --- a/vlib/v/checker/tests/ambiguous_field_method_err.out +++ b/vlib/v/checker/tests/ambiguous_field_method_err.out @@ -11,9 +11,29 @@ vlib/v/checker/tests/ambiguous_field_method_err.vv:22:4: error: ambiguous method | ~~~~~~ 23 | n := b.name 24 | } +vlib/v/checker/tests/ambiguous_field_method_err.vv:22:4: error: unknown method or field: `Bar.test` + 20 | fn main() { + 21 | b := Bar{} + 22 | b.test() + | ~~~~~~ + 23 | n := b.name + 24 | } vlib/v/checker/tests/ambiguous_field_method_err.vv:23:9: error: ambiguous field `name` 21 | b := Bar{} 22 | b.test() 23 | n := b.name | ~~~~ 24 | } +vlib/v/checker/tests/ambiguous_field_method_err.vv:23:9: error: type `Bar` has no field named `name`. +2 possibilities: `Foo2`, `Foo`. + 21 | b := Bar{} + 22 | b.test() + 23 | n := b.name + | ~~~~ + 24 | } +vlib/v/checker/tests/ambiguous_field_method_err.vv:23:4: error: assignment mismatch: 1 variable(s) 0 value(s) + 21 | b := Bar{} + 22 | b.test() + 23 | n := b.name + | ~~ + 24 | } diff --git a/vlib/v/checker/tests/ambiguous_function_call.out b/vlib/v/checker/tests/ambiguous_function_call.out index b88ef1a440..cd4e22ee55 100644 --- a/vlib/v/checker/tests/ambiguous_function_call.out +++ b/vlib/v/checker/tests/ambiguous_function_call.out @@ -11,3 +11,10 @@ vlib/v/checker/tests/ambiguous_function_call.vv:7:2: error: ambiguous call to: ` | ~~~~~~~~~~ 8 | } 9 | +vlib/v/checker/tests/ambiguous_function_call.vv:7:7: error: expected 0 arguments, but got 1 + 5 | fn foo2() { + 6 | foo2 := 1 + 7 | foo2(foo2) + | ~~~~ + 8 | } + 9 | diff --git a/vlib/v/checker/tests/anon_fn_arg_type_err.out b/vlib/v/checker/tests/anon_fn_arg_type_err.out index af0fb10383..0f283dceaf 100644 --- a/vlib/v/checker/tests/anon_fn_arg_type_err.out +++ b/vlib/v/checker/tests/anon_fn_arg_type_err.out @@ -12,6 +12,20 @@ vlib/v/checker/tests/anon_fn_arg_type_err.vv:7:10: error: `i` must be added to t | ^ 8 | } 9 | +vlib/v/checker/tests/anon_fn_arg_type_err.vv:7:3: error: `i` used as value + 5 | + 6 | func := fn (i) int { + 7 | return i + | ~~~~~~~~ + 8 | } + 9 | +vlib/v/checker/tests/anon_fn_arg_type_err.vv:6:14: error: unknown type `i` + 4 | mut i := 1 + 5 | + 6 | func := fn (i) int { + | ^ + 7 | return i + 8 | } vlib/v/checker/tests/anon_fn_arg_type_err.vv:10:15: error: cannot use `int` as `i` in argument 1 to `func` 8 | } 9 | diff --git a/vlib/v/checker/tests/any_int_float_ban_err.out b/vlib/v/checker/tests/any_int_float_ban_err.out index 510ab1856a..0d353e5bda 100644 --- a/vlib/v/checker/tests/any_int_float_ban_err.out +++ b/vlib/v/checker/tests/any_int_float_ban_err.out @@ -3,14 +3,19 @@ vlib/v/checker/tests/any_int_float_ban_err.vv:1:12: error: unknown type `int_lit | ~~~~~~~~~~~ 2 | type Fo2 = int_literal 3 | +vlib/v/checker/tests/any_int_float_ban_err.vv:1:26: error: unknown type `float_literal` + 1 | type Foo = int_literal | float_literal + | ~~~~~~~~~~~~~ + 2 | type Fo2 = int_literal + 3 | vlib/v/checker/tests/any_int_float_ban_err.vv:2:12: error: unknown type `int_literal` 1 | type Foo = int_literal | float_literal 2 | type Fo2 = int_literal | ~~~~~~~~~~~ - 3 | + 3 | 4 | struct Int { vlib/v/checker/tests/any_int_float_ban_err.vv:5:7: error: unknown type `int_literal` - 3 | + 3 | 4 | struct Int { 5 | i int_literal | ~~~~~~~~~~~ @@ -25,14 +30,14 @@ vlib/v/checker/tests/any_int_float_ban_err.vv:6:7: error: unknown type `float_li 8 | vlib/v/checker/tests/any_int_float_ban_err.vv:9:10: error: unknown type `int_literal` 7 | } - 8 | + 8 | 9 | fn foo(i int_literal) int_literal { | ~~~~~~~~~~~ 10 | return i 11 | } vlib/v/checker/tests/any_int_float_ban_err.vv:13:11: error: unknown type `int_literal` 11 | } - 12 | + 12 | 13 | fn foo2() int_literal { | ~~~~~~~~~~~ 14 | return 1 diff --git a/vlib/v/checker/tests/append_err.out b/vlib/v/checker/tests/append_err.out index 4c87f24ef2..faabf2cbc6 100644 --- a/vlib/v/checker/tests/append_err.out +++ b/vlib/v/checker/tests/append_err.out @@ -18,3 +18,15 @@ vlib/v/checker/tests/append_err.vv:6:9: error: array append cannot be used in an 6 | _ = (l << 3).len | ~~ 7 | } +vlib/v/checker/tests/append_err.vv:6:15: error: `(l << 3)` does not return a value + 4 | + 5 | _ = l << 3 + 6 | _ = (l << 3).len + | ~~~ + 7 | } +vlib/v/checker/tests/append_err.vv:6:4: error: assignment mismatch: 1 variable(s) 0 value(s) + 4 | + 5 | _ = l << 3 + 6 | _ = (l << 3).len + | ^ + 7 | } diff --git a/vlib/v/checker/tests/array_builtin_method_args_err.out b/vlib/v/checker/tests/array_builtin_method_args_err.out index db760305c3..45313a393e 100644 --- a/vlib/v/checker/tests/array_builtin_method_args_err.out +++ b/vlib/v/checker/tests/array_builtin_method_args_err.out @@ -1,28 +1,35 @@ vlib/v/checker/tests/array_builtin_method_args_err.vv:4:18: error: `.clone()` does not have any arguments 2 | arr := [1, 2, 3] - 3 | + 3 | 4 | a1 := arr.clone(22) | ~~ 5 | println(a1) 6 | vlib/v/checker/tests/array_builtin_method_args_err.vv:7:18: error: `.first()` does not have any arguments 5 | println(a1) - 6 | + 6 | 7 | a2 := arr.first('a2') | ~~~~ 8 | println(a2) 9 | vlib/v/checker/tests/array_builtin_method_args_err.vv:10:17: error: `.last()` does not have any arguments 8 | println(a2) - 9 | + 9 | 10 | a3 := arr.last(1) | ^ 11 | println(a3) 12 | vlib/v/checker/tests/array_builtin_method_args_err.vv:13:16: error: `.pop()` does not have any arguments 11 | println(a3) - 12 | + 12 | 13 | a4 := arr.pop(2) | ^ 14 | println(a4) 15 | } +vlib/v/checker/tests/array_builtin_method_args_err.vv:13:8: error: `arr` is immutable, declare it with `mut` to make it mutable + 11 | println(a3) + 12 | + 13 | a4 := arr.pop(2) + | ~~~ + 14 | println(a4) + 15 | } diff --git a/vlib/v/checker/tests/array_filter_map_option_function_err.out b/vlib/v/checker/tests/array_filter_map_option_function_err.out index eb4e34805b..de71105caa 100644 --- a/vlib/v/checker/tests/array_filter_map_option_function_err.out +++ b/vlib/v/checker/tests/array_filter_map_option_function_err.out @@ -1,21 +1,28 @@ vlib/v/checker/tests/array_filter_map_option_function_err.vv:14:25: error: option needs to be unwrapped before using it in map/filter 12 | } - 13 | + 13 | 14 | arr_struct2 := arr.map(option_mapping_struct) | ~~~~~~~~~~~~~~~~~~~~~ 15 | println(arr_struct2) 16 | vlib/v/checker/tests/array_filter_map_option_function_err.vv:17:18: error: option needs to be unwrapped before using it in map/filter 15 | println(arr_struct2) - 16 | + 16 | 17 | arr_int2 := arr.map(option_mapping_int) | ~~~~~~~~~~~~~~~~~~~~~~~ 18 | println(arr_int2) 19 | vlib/v/checker/tests/array_filter_map_option_function_err.vv:20:20: error: option needs to be unwrapped before using it in map/filter 18 | println(arr_int2) - 19 | + 19 | 20 | arr_filter := arr.filter(option_mapping_int) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 | println(arr_filter) - 22 | } \ No newline at end of file + 22 | } +vlib/v/checker/tests/array_filter_map_option_function_err.vv:20:27: error: type mismatch, should use `fn(a int) bool {...}` + 18 | println(arr_int2) + 19 | + 20 | arr_filter := arr.filter(option_mapping_int) + | ~~~~~~~~~~~~~~~~~~ + 21 | println(arr_filter) + 22 | } diff --git a/vlib/v/checker/tests/array_init_option_err.out b/vlib/v/checker/tests/array_init_option_err.out index 14412c4b41..c8981286fd 100644 --- a/vlib/v/checker/tests/array_init_option_err.out +++ b/vlib/v/checker/tests/array_init_option_err.out @@ -4,25 +4,30 @@ vlib/v/checker/tests/array_init_option_err.vv:2:38: error: cannot use unwrapped | ~~~~~ 3 | dump(arr1) 4 | -vlib/v/checker/tests/array_init_option_err.vv:5:20: error: cannot use unwrapped Option as length +vlib/v/checker/tests/array_init_option_err.vv:2:25: error: cannot use unwrapped Option as length + 1 | fn main() { + 2 | mut arr1 := []int{len: get(), init: get()} + | ~~~~~ 3 | dump(arr1) 4 | +vlib/v/checker/tests/array_init_option_err.vv:5:20: error: cannot use unwrapped Option as length + 3 | dump(arr1) + 4 | 5 | arr1 = []int{len: get(), init: get()?} | ~~~~~ 6 | dump(arr1) 7 | vlib/v/checker/tests/array_init_option_err.vv:8:34: error: cannot use unwrapped Option as initializer 6 | dump(arr1) - 7 | + 7 | 8 | arr1 = []int{len: get()?, init: get()} | ~~~~~ 9 | dump(arr1) 10 | vlib/v/checker/tests/array_init_option_err.vv:11:20: error: cannot use unwrapped Option as capacity 9 | dump(arr1) - 10 | + 10 | 11 | arr1 = []int{cap: get(), len: get()?, init: get()?} | ~~~~~ 12 | dump(arr1) 13 | } - diff --git a/vlib/v/checker/tests/array_literal_modify_err.out b/vlib/v/checker/tests/array_literal_modify_err.out index eaec4f986f..5629db6762 100644 --- a/vlib/v/checker/tests/array_literal_modify_err.out +++ b/vlib/v/checker/tests/array_literal_modify_err.out @@ -4,6 +4,12 @@ vlib/v/checker/tests/array_literal_modify_err.vv:2:24: error: array append canno | ~~ 3 | println(nums) 4 | } +vlib/v/checker/tests/array_literal_modify_err.vv:2:14: error: array literal can not be modified + 1 | fn main() { + 2 | mut nums := [1, 2, 3] << 4 + | ~~~~~~~~~ + 3 | println(nums) + 4 | } vlib/v/checker/tests/array_literal_modify_err.vv:3:2: error: `println` can not print void expressions 1 | fn main() { 2 | mut nums := [1, 2, 3] << 4 diff --git a/vlib/v/checker/tests/array_sort_err.out b/vlib/v/checker/tests/array_sort_err.out index 04c3dbf8f3..ad876660bb 100644 --- a/vlib/v/checker/tests/array_sort_err.out +++ b/vlib/v/checker/tests/array_sort_err.out @@ -25,3 +25,15 @@ vlib/v/checker/tests/array_sort_err.vv:6:9: error: `.sort()` can only use `a` or 6 | arr.sort(c > d) | ~~~~~~~~~~~ 7 | } +vlib/v/checker/tests/array_sort_err.vv:6:14: error: undefined ident: `c` + 4 | arr.sort(a == b) + 5 | arr.sort(a > a) + 6 | arr.sort(c > d) + | ^ + 7 | } +vlib/v/checker/tests/array_sort_err.vv:6:18: error: undefined ident: `d` + 4 | arr.sort(a == b) + 5 | arr.sort(a > a) + 6 | arr.sort(c > d) + | ^ + 7 | } diff --git a/vlib/v/checker/tests/array_sort_with_compare_err.out b/vlib/v/checker/tests/array_sort_with_compare_err.out index 3e8febe9eb..e73ff4f024 100644 --- a/vlib/v/checker/tests/array_sort_with_compare_err.out +++ b/vlib/v/checker/tests/array_sort_with_compare_err.out @@ -1,13 +1,20 @@ vlib/v/checker/tests/array_sort_with_compare_err.vv:11:24: error: sort_with_compare callback function parameter `a` with type `string` should be `&string` 9 | } - 10 | + 10 | 11 | fn sort_by_file_base(a string, b string) int { | ~~~~~~ 12 | return int(a > b) 13 | } +vlib/v/checker/tests/array_sort_with_compare_err.vv:11:34: error: sort_with_compare callback function parameter `b` with type `string` should be `&string` + 9 | } + 10 | + 11 | fn sort_by_file_base(a string, b string) int { + | ~~~~~~ + 12 | return int(a > b) + 13 | } vlib/v/checker/tests/array_sort_with_compare_err.vv:4:26: error: cannot use `fn (string, string) int` as `fn (voidptr, voidptr) int` in argument 1 to `[]string.sort_with_compare` 2 | mut names := ['aaa', 'bbb', 'ccc'] - 3 | + 3 | 4 | names.sort_with_compare(sort_by_file_base) | ~~~~~~~~~~~~~~~~~ 5 | println(names) @@ -15,7 +22,7 @@ vlib/v/checker/tests/array_sort_with_compare_err.vv:4:26: error: cannot use `fn Details: expected argument 1 to be a pointer, but the passed argument 1 is NOT a pointer vlib/v/checker/tests/array_sort_with_compare_err.vv:7:26: error: cannot use `int literal` as `fn (voidptr, voidptr) int` in argument 1 to `[]string.sort_with_compare` 5 | println(names) - 6 | + 6 | 7 | names.sort_with_compare(22) | ~~ 8 | println(names) diff --git a/vlib/v/checker/tests/array_sort_with_compare_ref_elem_err.out b/vlib/v/checker/tests/array_sort_with_compare_ref_elem_err.out index f7a60a01c0..ce19744dc8 100644 --- a/vlib/v/checker/tests/array_sort_with_compare_ref_elem_err.out +++ b/vlib/v/checker/tests/array_sort_with_compare_ref_elem_err.out @@ -1,7 +1,14 @@ vlib/v/checker/tests/array_sort_with_compare_ref_elem_err.vv:21:23: error: sort_with_compare callback function parameter `a` with type `&Cell` should be `&&Cell` 19 | } - 20 | + 20 | 21 | fn sort_cells_by_yx(a &Cell, b &Cell) int { | ~~~~~ 22 | if a.pos.y == b.pos.y { 23 | if a.pos.x < b.pos.x { +vlib/v/checker/tests/array_sort_with_compare_ref_elem_err.vv:21:32: error: sort_with_compare callback function parameter `b` with type `&Cell` should be `&&Cell` + 19 | } + 20 | + 21 | fn sort_cells_by_yx(a &Cell, b &Cell) int { + | ~~~~~ + 22 | if a.pos.y == b.pos.y { + 23 | if a.pos.x < b.pos.x { diff --git a/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.out b/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.out index d26ab1b0fd..ee93babb34 100644 --- a/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.out +++ b/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.out @@ -1,6 +1,18 @@ vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.vv:8:2: error: cannot dereference a function call on the left side of an assignment, use a temporary variable - 6 | + 6 | 7 | fn main() { 8 | *foo('s') = 1 | ^ 9 | } +vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.vv:8:12: error: modifying variables via dereferencing can only be done in `unsafe` blocks + 6 | + 7 | fn main() { + 8 | *foo('s') = 1 + | ^ + 9 | } +vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.vv:8:14: error: cannot assign to `*foo('s')`: expected `Foo`, not `int literal` + 6 | + 7 | fn main() { + 8 | *foo('s') = 1 + | ^ + 9 | } diff --git a/vlib/v/checker/tests/assign_expr_type_err_b.out b/vlib/v/checker/tests/assign_expr_type_err_b.out index e5f01cafc9..0cc90bb500 100644 --- a/vlib/v/checker/tests/assign_expr_type_err_b.out +++ b/vlib/v/checker/tests/assign_expr_type_err_b.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/assign_expr_type_err_b.vv:3:9: error: operator %= not defin | ~~~~~~~ 4 | _ = foo 5 | } +vlib/v/checker/tests/assign_expr_type_err_b.vv:3:9: error: cannot assign to `foo`: expected `int`, not `string` + 1 | fn main() { + 2 | mut foo := 10 + 3 | foo %= 'hello' + | ~~~~~~~ + 4 | _ = foo + 5 | } diff --git a/vlib/v/checker/tests/assign_expr_type_err_c.out b/vlib/v/checker/tests/assign_expr_type_err_c.out index 338ce5b87c..8d22c356b1 100644 --- a/vlib/v/checker/tests/assign_expr_type_err_c.out +++ b/vlib/v/checker/tests/assign_expr_type_err_c.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/assign_expr_type_err_c.vv:3:2: error: operator *= not defin | ~~~ 4 | _ = foo 5 | } +vlib/v/checker/tests/assign_expr_type_err_c.vv:3:9: error: cannot assign to `foo`: expected `string`, not `int literal` + 1 | fn main() { + 2 | mut foo := 'hello' + 3 | foo *= 10 + | ~~ + 4 | _ = foo + 5 | } diff --git a/vlib/v/checker/tests/assign_expr_type_err_d.out b/vlib/v/checker/tests/assign_expr_type_err_d.out index 77536290eb..62394fd909 100644 --- a/vlib/v/checker/tests/assign_expr_type_err_d.out +++ b/vlib/v/checker/tests/assign_expr_type_err_d.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/assign_expr_type_err_d.vv:3:9: error: operator /= not defin | ~~~~ 4 | _ = foo 5 | } +vlib/v/checker/tests/assign_expr_type_err_d.vv:3:9: error: cannot assign to `foo`: expected `f64`, not `bool` + 1 | fn main() { + 2 | mut foo := 1.5 + 3 | foo /= true + | ~~~~ + 4 | _ = foo + 5 | } diff --git a/vlib/v/checker/tests/assign_expr_type_err_e.out b/vlib/v/checker/tests/assign_expr_type_err_e.out index b8acd99bc0..ef10ad54d9 100644 --- a/vlib/v/checker/tests/assign_expr_type_err_e.out +++ b/vlib/v/checker/tests/assign_expr_type_err_e.out @@ -5,3 +5,17 @@ vlib/v/checker/tests/assign_expr_type_err_e.vv:3:2: error: operator `-=` not def | ~~~ 4 | _ = foo 5 | } +vlib/v/checker/tests/assign_expr_type_err_e.vv:3:9: error: invalid right operand: string -= rune + 1 | fn main() { + 2 | mut foo := 'hello' + 3 | foo -= `a` + | ~~~ + 4 | _ = foo + 5 | } +vlib/v/checker/tests/assign_expr_type_err_e.vv:3:9: error: cannot assign to `foo`: expected `string`, not `rune` + 1 | fn main() { + 2 | mut foo := 'hello' + 3 | foo -= `a` + | ~~~ + 4 | _ = foo + 5 | } diff --git a/vlib/v/checker/tests/assign_expr_type_err_f.out b/vlib/v/checker/tests/assign_expr_type_err_f.out index 7cdaa51a41..9775365706 100644 --- a/vlib/v/checker/tests/assign_expr_type_err_f.out +++ b/vlib/v/checker/tests/assign_expr_type_err_f.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/assign_expr_type_err_f.vv:3:9: error: invalid right operand | ~~~~~ 4 | _ = foo 5 | } +vlib/v/checker/tests/assign_expr_type_err_f.vv:3:9: error: cannot assign to `foo`: expected `int`, not `bool` + 1 | fn main() { + 2 | mut foo := 10 + 3 | foo -= false + | ~~~~~ + 4 | _ = foo + 5 | } diff --git a/vlib/v/checker/tests/assign_expr_type_err_h.out b/vlib/v/checker/tests/assign_expr_type_err_h.out index 07d2b6e9d1..55494b2e2c 100644 --- a/vlib/v/checker/tests/assign_expr_type_err_h.out +++ b/vlib/v/checker/tests/assign_expr_type_err_h.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/assign_expr_type_err_h.vv:3:9: error: invalid right operand | ~~~~~ 4 | _ = foo 5 | } +vlib/v/checker/tests/assign_expr_type_err_h.vv:3:9: error: cannot assign to `foo`: expected `string`, not `bool` + 1 | fn main() { + 2 | mut foo := 'hello' + 3 | foo += false + | ~~~~~ + 4 | _ = foo + 5 | } diff --git a/vlib/v/checker/tests/assign_expr_type_err_i.out b/vlib/v/checker/tests/assign_expr_type_err_i.out index c8450f0fd2..1799f7b2f5 100644 --- a/vlib/v/checker/tests/assign_expr_type_err_i.out +++ b/vlib/v/checker/tests/assign_expr_type_err_i.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/assign_expr_type_err_i.vv:3:9: error: invalid right operand | ~~~~~~~ 4 | _ = foo 5 | } +vlib/v/checker/tests/assign_expr_type_err_i.vv:3:9: error: cannot assign to `foo`: expected `f64`, not `string` + 1 | fn main() { + 2 | mut foo := 1.5 + 3 | foo += 'hello' + | ~~~~~~~ + 4 | _ = foo + 5 | } diff --git a/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.out b/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.out index 5c7e5cf955..0d82c14886 100644 --- a/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.out +++ b/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.out @@ -4,6 +4,12 @@ vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv:2:7: error: u | ^ 3 | b := c 4 | c := a +vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv:2:7: error: unresolved variable: `b` + 1 | fn main() { + 2 | a := b + | ^ + 3 | b := c + 4 | c := a vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv:3:7: error: undefined variable `c` (used before declaration) 1 | fn main() { 2 | a := b @@ -11,3 +17,10 @@ vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv:3:7: error: u | ^ 4 | c := a 5 | _ = a +vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv:3:7: error: unresolved variable: `c` + 1 | fn main() { + 2 | a := b + 3 | b := c + | ^ + 4 | c := a + 5 | _ = a diff --git a/vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.out b/vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.out index 0c25302819..85e2184a99 100644 --- a/vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.out +++ b/vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.out @@ -1,10 +1,3 @@ -vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:11:12: warning: redundant parentheses are used - 9 | fn foo() { - 10 | mut a := &(a_char) - 11 | mut b := &((a_char)) - | ~~~~~~~~~~ - 12 | mut c := &((((a_char)))) - 13 | println(a) vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:11:12: warning: redundant parentheses are used 9 | fn foo() { 10 | mut a := &(a_char) @@ -19,41 +12,6 @@ vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:12:1 | ~~~~~~~~~~~~~~ 13 | println(a) 14 | println(b) -vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:12:13: warning: redundant parentheses are used - 10 | mut a := &(a_char) - 11 | mut b := &((a_char)) - 12 | mut c := &((((a_char)))) - | ~~~~~~~~~~~~ - 13 | println(a) - 14 | println(b) -vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:12:14: warning: redundant parentheses are used - 10 | mut a := &(a_char) - 11 | mut b := &((a_char)) - 12 | mut c := &((((a_char)))) - | ~~~~~~~~~~ - 13 | println(a) - 14 | println(b) -vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:12:12: warning: redundant parentheses are used - 10 | mut a := &(a_char) - 11 | mut b := &((a_char)) - 12 | mut c := &((((a_char)))) - | ~~~~~~~~~~~~~~ - 13 | println(a) - 14 | println(b) -vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:12:13: warning: redundant parentheses are used - 10 | mut a := &(a_char) - 11 | mut b := &((a_char)) - 12 | mut c := &((((a_char)))) - | ~~~~~~~~~~~~ - 13 | println(a) - 14 | println(b) -vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:12:14: warning: redundant parentheses are used - 10 | mut a := &(a_char) - 11 | mut b := &((a_char)) - 12 | mut c := &((((a_char)))) - | ~~~~~~~~~~ - 13 | println(a) - 14 | println(b) vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:10:11: error: `a_char` is immutable, cannot have a mutable reference to it 8 | 9 | fn foo() { diff --git a/vlib/v/checker/tests/assign_multi_immutable_err.out b/vlib/v/checker/tests/assign_multi_immutable_err.out index 635e02059c..13606c279c 100644 --- a/vlib/v/checker/tests/assign_multi_immutable_err.out +++ b/vlib/v/checker/tests/assign_multi_immutable_err.out @@ -3,15 +3,29 @@ vlib/v/checker/tests/assign_multi_immutable_err.vv:4:2: error: `a` is immutable, 3 | b := 20 4 | a, b = 1, 2 | ^ - 5 | + 5 | + 6 | println('$a, $b') +vlib/v/checker/tests/assign_multi_immutable_err.vv:4:5: error: `b` is immutable, declare it with `mut` to make it mutable + 2 | a := 10 + 3 | b := 20 + 4 | a, b = 1, 2 + | ^ + 5 | 6 | println('$a, $b') vlib/v/checker/tests/assign_multi_immutable_err.vv:18:5: error: cannot assign to function `error` - 16 | + 16 | 17 | fn assign_fn() { 18 | _, error = g() | ~~~~~ 19 | g = f() 20 | } +vlib/v/checker/tests/assign_multi_immutable_err.vv:18:13: error: cannot assign to `error`: expected `fn (string) IError`, not `int` + 16 | + 17 | fn assign_fn() { + 18 | _, error = g() + | ~~~ + 19 | g = f() + 20 | } vlib/v/checker/tests/assign_multi_immutable_err.vv:19:2: error: cannot assign to function `g` 17 | fn assign_fn() { 18 | _, error = g() @@ -19,3 +33,10 @@ vlib/v/checker/tests/assign_multi_immutable_err.vv:19:2: error: cannot assign to | ^ 20 | } 21 | +vlib/v/checker/tests/assign_multi_immutable_err.vv:19:6: error: cannot assign to `g`: expected `fn () (int, int)`, not `int` + 17 | fn assign_fn() { + 18 | _, error = g() + 19 | g = f() + | ~~~ + 20 | } + 21 | diff --git a/vlib/v/checker/tests/assign_multi_mismatch.out b/vlib/v/checker/tests/assign_multi_mismatch.out index ded3db72c5..dfea5a2583 100644 --- a/vlib/v/checker/tests/assign_multi_mismatch.out +++ b/vlib/v/checker/tests/assign_multi_mismatch.out @@ -33,6 +33,13 @@ vlib/v/checker/tests/assign_multi_mismatch.vv:10:15: error: cannot use multi-val | ~~~ 11 | _, _, _ := f(), 0 12 | _, _ := f(), f() +vlib/v/checker/tests/assign_multi_mismatch.vv:10:9: error: assignment mismatch: 3 variable(s) 2 value(s) + 8 | _, _ := 0, f() + 9 | _, _ := f(), 0 + 10 | _, _, _ := 0, f() + | ~~ + 11 | _, _, _ := f(), 0 + 12 | _, _ := f(), f() vlib/v/checker/tests/assign_multi_mismatch.vv:11:12: error: cannot use multi-value (int, int) in single-value context 9 | _, _ := f(), 0 10 | _, _, _ := 0, f() @@ -40,6 +47,13 @@ vlib/v/checker/tests/assign_multi_mismatch.vv:11:12: error: cannot use multi-val | ~~~ 12 | _, _ := f(), f() 13 | _, _, _, _ := f(), f() +vlib/v/checker/tests/assign_multi_mismatch.vv:11:9: error: assignment mismatch: 3 variable(s) but `f()` returns 2 value(s) + 9 | _, _ := f(), 0 + 10 | _, _, _ := 0, f() + 11 | _, _, _ := f(), 0 + | ~~ + 12 | _, _ := f(), f() + 13 | _, _, _, _ := f(), f() vlib/v/checker/tests/assign_multi_mismatch.vv:12:9: error: cannot use multi-value (int, int) in single-value context 10 | _, _, _ := 0, f() 11 | _, _, _ := f(), 0 @@ -54,6 +68,13 @@ vlib/v/checker/tests/assign_multi_mismatch.vv:13:15: error: cannot use multi-val | ~~~ 14 | 15 | _, _ := 0, match 4 { +vlib/v/checker/tests/assign_multi_mismatch.vv:13:12: error: assignment mismatch: 4 variable(s) but `f()` returns 2 value(s) + 11 | _, _, _ := f(), 0 + 12 | _, _ := f(), f() + 13 | _, _, _, _ := f(), f() + | ~~ + 14 | + 15 | _, _ := 0, match 4 { vlib/v/checker/tests/assign_multi_mismatch.vv:19:3: error: assignment mismatch: 1 variable(s) 2 value(s) 17 | else { 1 } 18 | } diff --git a/vlib/v/checker/tests/assign_to_typeless_variable_err.out b/vlib/v/checker/tests/assign_to_typeless_variable_err.out index 37ab5d3005..2566b150a9 100644 --- a/vlib/v/checker/tests/assign_to_typeless_variable_err.out +++ b/vlib/v/checker/tests/assign_to_typeless_variable_err.out @@ -16,3 +16,9 @@ vlib/v/checker/tests/assign_to_typeless_variable_err.vv:3:3: error: `val` is imm 3 | val = 1 | ~~~ 4 | } +vlib/v/checker/tests/assign_to_typeless_variable_err.vv:3:9: error: cannot assign to `val`: expected `void`, not `int literal` + 1 | fn main() { + 2 | val := {} + 3 | val = 1 + | ^ + 4 | } diff --git a/vlib/v/checker/tests/blank_ident_invalid_use.out b/vlib/v/checker/tests/blank_ident_invalid_use.out index 9385664f59..3f719b58e5 100644 --- a/vlib/v/checker/tests/blank_ident_invalid_use.out +++ b/vlib/v/checker/tests/blank_ident_invalid_use.out @@ -3,3 +3,8 @@ vlib/v/checker/tests/blank_ident_invalid_use.vv:2:8: error: undefined ident: `_` 2 | _ := [_] | ^ 3 | } +vlib/v/checker/tests/blank_ident_invalid_use.vv:2:8: error: invalid void array element type + 1 | fn main() { + 2 | _ := [_] + | ^ + 3 | } diff --git a/vlib/v/checker/tests/cannot_cast_to_struct.out b/vlib/v/checker/tests/cannot_cast_to_struct.out index 8445bb1b1e..889a1625ed 100644 --- a/vlib/v/checker/tests/cannot_cast_to_struct.out +++ b/vlib/v/checker/tests/cannot_cast_to_struct.out @@ -19,6 +19,13 @@ vlib/v/checker/tests/cannot_cast_to_struct.vv:12:6: error: cannot cast `Alphabet | ~~~~~~~~ 13 | _ = Xyz(5) 14 | s := Abc{} +vlib/v/checker/tests/cannot_cast_to_struct.vv:12:6: error: cannot cast `Alphabet` sum type value to `Xyz`, use `sum as Xyz` instead + 10 | _ := Test(Abc{}) + 11 | sum := Alphabet(Xyz{}) + 12 | _ = Xyz(sum) + | ~~~~~~~~ + 13 | _ = Xyz(5) + 14 | s := Abc{} vlib/v/checker/tests/cannot_cast_to_struct.vv:13:6: error: cannot cast `int literal` to struct 11 | sum := Alphabet(Xyz{}) 12 | _ = Xyz(sum) diff --git a/vlib/v/checker/tests/cast_string_err.out b/vlib/v/checker/tests/cast_string_err.out index 86625cf033..f33fc50c05 100644 --- a/vlib/v/checker/tests/cast_string_err.out +++ b/vlib/v/checker/tests/cast_string_err.out @@ -12,6 +12,13 @@ vlib/v/checker/tests/cast_string_err.vv:18:9: error: cannot cast sumtype `Sumtyp | ~~~~~~~~~~ 19 | println(sst) 20 | // +vlib/v/checker/tests/cast_string_err.vv:18:9: error: cannot cast `Sumtype` sum type value to `string`, use `st as string` instead + 16 | // + 17 | st := Sumtype(int(456)) + 18 | sst := string(st) + | ~~~~~~~~~~ + 19 | println(sst) + 20 | // vlib/v/checker/tests/cast_string_err.vv:22:10: error: cannot cast struct `Abc` to `string` 20 | // 21 | abc := Abc{} diff --git a/vlib/v/checker/tests/chan_mut.out b/vlib/v/checker/tests/chan_mut.out index e82419b97d..b2b6c96a9b 100644 --- a/vlib/v/checker/tests/chan_mut.out +++ b/vlib/v/checker/tests/chan_mut.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/chan_mut.vv:8:8: error: `v` is immutable, declare it with ` | ^ 9 | mut w := St{} 10 | ch <- w +vlib/v/checker/tests/chan_mut.vv:8:8: error: cannot push non-reference `St` on `chan mut St` + 6 | fn f(ch chan mut St) { + 7 | v := St{} + 8 | ch <- v + | ^ + 9 | mut w := St{} + 10 | ch <- w vlib/v/checker/tests/chan_mut.vv:10:8: error: cannot push non-reference `St` on `chan mut St` 8 | ch <- v 9 | mut w := St{} diff --git a/vlib/v/checker/tests/comptime_call_no_unused_var.out b/vlib/v/checker/tests/comptime_call_no_unused_var.out index 17aae7c95a..0aecbc4ca1 100644 --- a/vlib/v/checker/tests/comptime_call_no_unused_var.out +++ b/vlib/v/checker/tests/comptime_call_no_unused_var.out @@ -19,6 +19,13 @@ vlib/v/checker/tests/comptime_call_no_unused_var.vv:15:8: error: todo: not a str | ^ 16 | s2 := 'x' 17 | test.$s2() +vlib/v/checker/tests/comptime_call_no_unused_var.vv:15:8: error: could not find method `` + 13 | test.$v() + 14 | s := 'x' + 'y' + 15 | test.$s() + | ^ + 16 | s2 := 'x' + 17 | test.$s2() vlib/v/checker/tests/comptime_call_no_unused_var.vv:17:8: error: could not find method `x` 15 | test.$s() 16 | s2 := 'x' diff --git a/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.out b/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.out index bc3e1f95f8..6b7a2bb723 100644 --- a/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.out +++ b/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/comptime_field_selector_not_in_for_err.vv:9:6: error: expec | ~~~~ 10 | } 11 | +vlib/v/checker/tests/comptime_field_selector_not_in_for_err.vv:9:14: error: cannot assign to `t.$(name)`: expected `void`, not `string` + 7 | mut t := T{} + 8 | name := 'test' + 9 | t.$(name) = '3' + | ~~~ + 10 | } + 11 | diff --git a/vlib/v/checker/tests/comptime_field_selector_not_name_err.out b/vlib/v/checker/tests/comptime_field_selector_not_name_err.out index c53955c555..4461226740 100644 --- a/vlib/v/checker/tests/comptime_field_selector_not_name_err.out +++ b/vlib/v/checker/tests/comptime_field_selector_not_name_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:10:8: error: expect | ^ 11 | fv := Foo{} 12 | _ = t.$(fv.name) +vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:10:8: error: expected selector expression e.g. `$(field.name)` + 8 | $for f in T.fields { + 9 | $if f.typ is string { + 10 | t.$(f) = '3' + | ^ + 11 | fv := Foo{} + 12 | _ = t.$(fv.name) vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:12:12: error: unknown `$for` variable `fv` 10 | t.$(f) = '3' 11 | fv := Foo{} @@ -19,3 +26,17 @@ vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:15:10: error: undef | ^ 16 | } 17 | +vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:15:12: error: `f` does not return a value + 13 | } + 14 | } + 15 | _ = t.$(f.name) + | ~~~~ + 16 | } + 17 | +vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:15:12: error: expected `string` instead of `void` (e.g. `field.name`) + 13 | } + 14 | } + 15 | _ = t.$(f.name) + | ~~~~ + 16 | } + 17 | diff --git a/vlib/v/checker/tests/const_cycle_decl_err.out b/vlib/v/checker/tests/const_cycle_decl_err.out index 9cb350cc54..1bdc829219 100644 --- a/vlib/v/checker/tests/const_cycle_decl_err.out +++ b/vlib/v/checker/tests/const_cycle_decl_err.out @@ -1,3 +1,6 @@ vlib/v/checker/tests/const_cycle_decl_err.vv:1:11: error: cycle in constant `a` 1 | const a = a + 0 | ^ +vlib/v/checker/tests/const_cycle_decl_err.vv:1:11: error: mismatched types `void` and `int literal` + 1 | const a = a + 0 + | ~~~~~ diff --git a/vlib/v/checker/tests/const_expr_match_range_invalid_err.out b/vlib/v/checker/tests/const_expr_match_range_invalid_err.out index 21d35d878d..89e1b23766 100644 --- a/vlib/v/checker/tests/const_expr_match_range_invalid_err.out +++ b/vlib/v/checker/tests/const_expr_match_range_invalid_err.out @@ -18,3 +18,20 @@ vlib/v/checker/tests/const_expr_match_range_invalid_err.vv:9:2: error: the low a Details: low part type: string high part type: int literal +vlib/v/checker/tests/const_expr_match_range_invalid_err.vv:9:2: error: the range type and the match condition type should match + 7 | println(start) + 8 | } + 9 | 'str'...end { + | ~~~~~~~~~~~ + 10 | println(end) + 11 | } +Details: +match condition type: int + range type: string +vlib/v/checker/tests/const_expr_match_range_invalid_err.vv:9:2: error: match branch range expressions need the start value to be known at compile time (only enums, const or literals are supported) + 7 | println(start) + 8 | } + 9 | 'str'...end { + | ~~~~~ + 10 | println(end) + 11 | } diff --git a/vlib/v/checker/tests/const_match_invalid_type_range_err.out b/vlib/v/checker/tests/const_match_invalid_type_range_err.out index 792fbcdd36..dc4eb5c53a 100644 --- a/vlib/v/checker/tests/const_match_invalid_type_range_err.out +++ b/vlib/v/checker/tests/const_match_invalid_type_range_err.out @@ -8,6 +8,13 @@ vlib/v/checker/tests/const_match_invalid_type_range_err.vv:6:2: error: the range Details: match condition type: int range type: rune +vlib/v/checker/tests/const_match_invalid_type_range_err.vv:6:2: error: the start value `97` should be lower than the end value `2` + 4 | + 5 | match 5 { + 6 | start...end { + | ~~~~~~~~~~~ + 7 | println(start) + 8 | } vlib/v/checker/tests/const_match_invalid_type_range_err.vv:13:2: error: the range type and the match condition type should match 11 | 12 | b := match 5 { @@ -18,3 +25,10 @@ vlib/v/checker/tests/const_match_invalid_type_range_err.vv:13:2: error: the rang Details: match condition type: int range type: rune +vlib/v/checker/tests/const_match_invalid_type_range_err.vv:13:2: error: the start value `97` should be lower than the end value `2` + 11 | + 12 | b := match 5 { + 13 | start...end { + | ~~~~~~~~~~~ + 14 | 3 + 15 | } diff --git a/vlib/v/checker/tests/const_match_mismatch_end_range_err.out b/vlib/v/checker/tests/const_match_mismatch_end_range_err.out index b654b77ffb..c21b1d1570 100644 --- a/vlib/v/checker/tests/const_match_mismatch_end_range_err.out +++ b/vlib/v/checker/tests/const_match_mismatch_end_range_err.out @@ -18,6 +18,13 @@ vlib/v/checker/tests/const_match_mismatch_end_range_err.vv:9:2: error: the range Details: match condition type: int range type: rune +vlib/v/checker/tests/const_match_mismatch_end_range_err.vv:9:2: error: the start value `97` should be lower than the end value `12` + 7 | println(start) + 8 | } + 9 | `a`...start { + | ~~~~~~~~~~~ + 10 | println(end) + 11 | } vlib/v/checker/tests/const_match_mismatch_end_range_err.vv:16:2: error: the range type and the match condition type should match 14 | 15 | a := match 5 { @@ -38,3 +45,10 @@ vlib/v/checker/tests/const_match_mismatch_end_range_err.vv:19:2: error: the rang Details: match condition type: int range type: rune +vlib/v/checker/tests/const_match_mismatch_end_range_err.vv:19:2: error: the start value `97` should be lower than the end value `12` + 17 | 1 + 18 | } + 19 | `a`...start { + | ~~~~~~~~~~~ + 20 | `a` + 21 | } diff --git a/vlib/v/checker/tests/const_match_range_duplicate_case_err.out b/vlib/v/checker/tests/const_match_range_duplicate_case_err.out index b23875977d..9b4f76aa7d 100644 --- a/vlib/v/checker/tests/const_match_range_duplicate_case_err.out +++ b/vlib/v/checker/tests/const_match_range_duplicate_case_err.out @@ -5,6 +5,76 @@ vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match c | ~~~~~~~~~~~ 10 | println(3) 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `3` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `4` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `5` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `6` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `7` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `8` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `9` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `10` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `11` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:9:2: error: match case `12` is handled more than once + 7 | println(1) + 8 | } + 9 | start...end { + | ~~~~~~~~~~~ + 10 | println(3) + 11 | } vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `2` is handled more than once 19 | 1 20 | } @@ -12,3 +82,73 @@ vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match | ~~~~~~~~~~~ 22 | 3 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `3` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `4` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `5` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `6` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `7` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `8` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `9` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `10` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `11` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } +vlib/v/checker/tests/const_match_range_duplicate_case_err.vv:21:2: error: match case `12` is handled more than once + 19 | 1 + 20 | } + 21 | start...end { + | ~~~~~~~~~~~ + 22 | 3 + 23 | } diff --git a/vlib/v/checker/tests/const_match_type_mismatch_range_err.out b/vlib/v/checker/tests/const_match_type_mismatch_range_err.out index 768c2a4124..9df1cea105 100644 --- a/vlib/v/checker/tests/const_match_type_mismatch_range_err.out +++ b/vlib/v/checker/tests/const_match_type_mismatch_range_err.out @@ -8,6 +8,23 @@ vlib/v/checker/tests/const_match_type_mismatch_range_err.vv:6:2: error: the low Details: low part type: string high part type: int literal +vlib/v/checker/tests/const_match_type_mismatch_range_err.vv:6:2: error: the range type and the match condition type should match + 4 | + 5 | match 5 { + 6 | start...end { + | ~~~~~~~~~~~ + 7 | println(start) + 8 | } +Details: +match condition type: int + range type: string +vlib/v/checker/tests/const_match_type_mismatch_range_err.vv:6:2: error: match branch range expressions need the start value to be known at compile time (only enums, const or literals are supported) + 4 | + 5 | match 5 { + 6 | start...end { + | ~~~~~ + 7 | println(start) + 8 | } vlib/v/checker/tests/const_match_type_mismatch_range_err.vv:13:2: error: the low and high parts of a range expression, should have matching types 11 | 12 | z := match 5 { @@ -18,3 +35,20 @@ vlib/v/checker/tests/const_match_type_mismatch_range_err.vv:13:2: error: the low Details: low part type: string high part type: int literal +vlib/v/checker/tests/const_match_type_mismatch_range_err.vv:13:2: error: the range type and the match condition type should match + 11 | + 12 | z := match 5 { + 13 | start...end { + | ~~~~~~~~~~~ + 14 | 2 + 15 | } +Details: +match condition type: int + range type: string +vlib/v/checker/tests/const_match_type_mismatch_range_err.vv:13:2: error: match branch range expressions need the start value to be known at compile time (only enums, const or literals are supported) + 11 | + 12 | z := match 5 { + 13 | start...end { + | ~~~~~ + 14 | 2 + 15 | } diff --git a/vlib/v/checker/tests/custom_comptime_define_error.out b/vlib/v/checker/tests/custom_comptime_define_error.out index 6d48ace842..a0db877460 100644 --- a/vlib/v/checker/tests/custom_comptime_define_error.out +++ b/vlib/v/checker/tests/custom_comptime_define_error.out @@ -4,4 +4,11 @@ vlib/v/checker/tests/custom_comptime_define_error.vv:6:6: error: undefined ident 6 | $if mysymbol { | ~~~~~~~~ 7 | // this will produce a checker error when `-d mysymbol` is not given on the CLI - 8 | println('comptime non-option define works') \ No newline at end of file + 8 | println('comptime non-option define works') +vlib/v/checker/tests/custom_comptime_define_error.vv:6:2: error: unknown var: `mysymbol` + 4 | println('comptime option define works') + 5 | } + 6 | $if mysymbol { + | ~~~~~~~~~~~~ + 7 | // this will produce a checker error when `-d mysymbol` is not given on the CLI + 8 | println('comptime non-option define works') diff --git a/vlib/v/checker/tests/decompose_type_err.out b/vlib/v/checker/tests/decompose_type_err.out index 95d56f66c0..4cf8931dc6 100644 --- a/vlib/v/checker/tests/decompose_type_err.out +++ b/vlib/v/checker/tests/decompose_type_err.out @@ -1,6 +1,12 @@ vlib/v/checker/tests/decompose_type_err.vv:4:13: error: decomposition can only be used on arrays - 2 | + 2 | 3 | fn main() { 4 | varargs(...123) | ~~~ - 5 | } \ No newline at end of file + 5 | } +vlib/v/checker/tests/decompose_type_err.vv:4:10: error: `ast.ArrayDecompose` (no value) used as value in argument 1 to `varargs` + 2 | + 3 | fn main() { + 4 | varargs(...123) + | ~~~~~~ + 5 | } diff --git a/vlib/v/checker/tests/defer_use_multi_return_value_with_index_out_of_bounds.out b/vlib/v/checker/tests/defer_use_multi_return_value_with_index_out_of_bounds.out index 08cdc16849..7355d6f59c 100644 --- a/vlib/v/checker/tests/defer_use_multi_return_value_with_index_out_of_bounds.out +++ b/vlib/v/checker/tests/defer_use_multi_return_value_with_index_out_of_bounds.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/defer_use_multi_return_value_with_index_out_of_bounds.vv:3: | ~~~~~~~ 4 | } 5 | return 'test', 'test2' +vlib/v/checker/tests/defer_use_multi_return_value_with_index_out_of_bounds.vv:3:3: error: `println` can not print void expressions + 1 | fn test() (string, string) { + 2 | defer { + 3 | println($res(2)) + | ~~~~~~~~~~~~~~~~ + 4 | } + 5 | return 'test', 'test2' diff --git a/vlib/v/checker/tests/defer_use_multi_return_value_without_index.out b/vlib/v/checker/tests/defer_use_multi_return_value_without_index.out index 70898e96c4..369cadbd64 100644 --- a/vlib/v/checker/tests/defer_use_multi_return_value_without_index.out +++ b/vlib/v/checker/tests/defer_use_multi_return_value_without_index.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/defer_use_multi_return_value_without_index.vv:3:11: error: | ~~~~~~ 4 | } 5 | return 'test', 'test2' +vlib/v/checker/tests/defer_use_multi_return_value_without_index.vv:3:3: error: `println` can not print void expressions + 1 | fn test() (string, string) { + 2 | defer { + 3 | println($res()) + | ~~~~~~~~~~~~~~~ + 4 | } + 5 | return 'test', 'test2' diff --git a/vlib/v/checker/tests/defer_use_returned_value_when_nothing_is_returned.out b/vlib/v/checker/tests/defer_use_returned_value_when_nothing_is_returned.out index 88094686f5..6c13487981 100644 --- a/vlib/v/checker/tests/defer_use_returned_value_when_nothing_is_returned.out +++ b/vlib/v/checker/tests/defer_use_returned_value_when_nothing_is_returned.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/defer_use_returned_value_when_nothing_is_returned.vv:3:11: | ~~~~~~ 4 | } 5 | } +vlib/v/checker/tests/defer_use_returned_value_when_nothing_is_returned.vv:3:3: error: `println` can not print void expressions + 1 | fn test() { + 2 | defer { + 3 | println($res()) + | ~~~~~~~~~~~~~~~ + 4 | } + 5 | } diff --git a/vlib/v/checker/tests/defer_use_returned_value_when_result_is_returned.out b/vlib/v/checker/tests/defer_use_returned_value_when_result_is_returned.out index ca8995cdc5..fccaf01f45 100644 --- a/vlib/v/checker/tests/defer_use_returned_value_when_result_is_returned.out +++ b/vlib/v/checker/tests/defer_use_returned_value_when_result_is_returned.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/defer_use_returned_value_when_result_is_returned.vv:3:11: e | ~~~~~~ 4 | } 5 | return 'test' +vlib/v/checker/tests/defer_use_returned_value_when_result_is_returned.vv:3:3: error: `println` can not print void expressions + 1 | fn test() !string { + 2 | defer { + 3 | println($res()) + | ~~~~~~~~~~~~~~~ + 4 | } + 5 | return 'test' diff --git a/vlib/v/checker/tests/div_op_wrong_type_err.out b/vlib/v/checker/tests/div_op_wrong_type_err.out index f79c286a71..aecfce2d18 100644 --- a/vlib/v/checker/tests/div_op_wrong_type_err.out +++ b/vlib/v/checker/tests/div_op_wrong_type_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/div_op_wrong_type_err.vv:3:13: error: mismatched types `Aaa | ~~~~~~~~~~ 4 | println(10 / Aaa{}) 5 | println([1,2,3] / 10) +vlib/v/checker/tests/div_op_wrong_type_err.vv:3:13: error: infix expr: cannot use `int literal` (right expression) as `Aaa` + 1 | struct Aaa{} + 2 | fn main() { + 3 | println(Aaa{} / 10) + | ~~~~~~~~~~ + 4 | println(10 / Aaa{}) + 5 | println([1,2,3] / 10) vlib/v/checker/tests/div_op_wrong_type_err.vv:4:13: error: mismatched types `int literal` and `Aaa` 2 | fn main() { 3 | println(Aaa{} / 10) @@ -12,6 +19,13 @@ vlib/v/checker/tests/div_op_wrong_type_err.vv:4:13: error: mismatched types `int | ~~~~~~~~~~ 5 | println([1,2,3] / 10) 6 | println(10 / [1,2,3]) +vlib/v/checker/tests/div_op_wrong_type_err.vv:4:13: error: infix expr: cannot use `Aaa` (right expression) as `int literal` + 2 | fn main() { + 3 | println(Aaa{} / 10) + 4 | println(10 / Aaa{}) + | ~~~~~~~~~~ + 5 | println([1,2,3] / 10) + 6 | println(10 / [1,2,3]) vlib/v/checker/tests/div_op_wrong_type_err.vv:5:13: error: mismatched types `[]int` and `int literal` 3 | println(Aaa{} / 10) 4 | println(10 / Aaa{}) @@ -19,6 +33,13 @@ vlib/v/checker/tests/div_op_wrong_type_err.vv:5:13: error: mismatched types `[]i | ~~~~~~~~~~~~ 6 | println(10 / [1,2,3]) 7 | a := map[string]int +vlib/v/checker/tests/div_op_wrong_type_err.vv:5:13: error: infix expr: cannot use `int literal` (right expression) as `[]int` + 3 | println(Aaa{} / 10) + 4 | println(10 / Aaa{}) + 5 | println([1,2,3] / 10) + | ~~~~~~~~~~~~ + 6 | println(10 / [1,2,3]) + 7 | a := map[string]int vlib/v/checker/tests/div_op_wrong_type_err.vv:6:13: error: mismatched types `int literal` and `[]int` 4 | println(10 / Aaa{}) 5 | println([1,2,3] / 10) @@ -26,6 +47,13 @@ vlib/v/checker/tests/div_op_wrong_type_err.vv:6:13: error: mismatched types `int | ~~~~~~~~~~~~ 7 | a := map[string]int 8 | println(a / 10) +vlib/v/checker/tests/div_op_wrong_type_err.vv:6:13: error: infix expr: cannot use `[]int` (right expression) as `int literal` + 4 | println(10 / Aaa{}) + 5 | println([1,2,3] / 10) + 6 | println(10 / [1,2,3]) + | ~~~~~~~~~~~~ + 7 | a := map[string]int + 8 | println(a / 10) vlib/v/checker/tests/div_op_wrong_type_err.vv:8:13: error: mismatched types `map[string]int` and `int literal` 6 | println(10 / [1,2,3]) 7 | a := map[string]int @@ -33,10 +61,22 @@ vlib/v/checker/tests/div_op_wrong_type_err.vv:8:13: error: mismatched types `map | ~~~~~~ 9 | println(10 / a) 10 | } +vlib/v/checker/tests/div_op_wrong_type_err.vv:8:13: error: infix expr: cannot use `int literal` (right expression) as `map[string]int` + 6 | println(10 / [1,2,3]) + 7 | a := map[string]int + 8 | println(a / 10) + | ~~~~~~ + 9 | println(10 / a) + 10 | } vlib/v/checker/tests/div_op_wrong_type_err.vv:9:13: error: mismatched types `int literal` and `map[string]int` 7 | a := map[string]int 8 | println(a / 10) 9 | println(10 / a) | ~~~~~~ 10 | } - +vlib/v/checker/tests/div_op_wrong_type_err.vv:9:13: error: infix expr: cannot use `map[string]int` (right expression) as `int literal` + 7 | a := map[string]int + 8 | println(a / 10) + 9 | println(10 / a) + | ~~~~~~ + 10 | } diff --git a/vlib/v/checker/tests/enum_op_err.out b/vlib/v/checker/tests/enum_op_err.out index 1392251852..4d69b14c4e 100644 --- a/vlib/v/checker/tests/enum_op_err.out +++ b/vlib/v/checker/tests/enum_op_err.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/enum_op_err.vv:8:20: error: only `==` and `!=` are defined on `enum`, use an explicit cast to `int` if needed - 6 | + 6 | 7 | fn main() { 8 | println(Color.red > Color.green) | ^ @@ -19,6 +19,20 @@ vlib/v/checker/tests/enum_op_err.vv:10:10: error: left operand for `&&` is not a | ~~~~~~~~~ 11 | println(Color.red | Color.green) 12 | println(Color.red & Color.green) +vlib/v/checker/tests/enum_op_err.vv:10:23: error: right operand for `&&` is not a boolean + 8 | println(Color.red > Color.green) + 9 | println(Color.red + Color.green) + 10 | println(Color.red && Color.green) + | ~~~~~~~~~~~ + 11 | println(Color.red | Color.green) + 12 | println(Color.red & Color.green) +vlib/v/checker/tests/enum_op_err.vv:10:20: error: only `==` and `!=` are defined on `enum`, use an explicit cast to `int` if needed + 8 | println(Color.red > Color.green) + 9 | println(Color.red + Color.green) + 10 | println(Color.red && Color.green) + | ~~ + 11 | println(Color.red | Color.green) + 12 | println(Color.red & Color.green) vlib/v/checker/tests/enum_op_err.vv:11:20: error: only `==` and `!=` are defined on `enum`, use an explicit cast to `int` if needed 9 | println(Color.red + Color.green) 10 | println(Color.red && Color.green) diff --git a/vlib/v/checker/tests/enum_op_flag_err.out b/vlib/v/checker/tests/enum_op_flag_err.out index fb3e228e0a..cf9ce5117a 100644 --- a/vlib/v/checker/tests/enum_op_flag_err.out +++ b/vlib/v/checker/tests/enum_op_flag_err.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/enum_op_flag_err.vv:9:24: error: only `==`, `!=`, `|` and `&` are defined on `[flag]` tagged `enum`, use an explicit cast to `int` if needed - 7 | + 7 | 8 | fn main() { 9 | println(FilePerm.read > FilePerm.write) | ^ @@ -18,3 +18,15 @@ vlib/v/checker/tests/enum_op_flag_err.vv:11:10: error: left operand for `&&` is 11 | println(FilePerm.write && FilePerm.exec) | ~~~~~~~~~~~~~~ 12 | } +vlib/v/checker/tests/enum_op_flag_err.vv:11:28: error: right operand for `&&` is not a boolean + 9 | println(FilePerm.read > FilePerm.write) + 10 | println(FilePerm.write + FilePerm.exec) + 11 | println(FilePerm.write && FilePerm.exec) + | ~~~~~~~~~~~~~ + 12 | } +vlib/v/checker/tests/enum_op_flag_err.vv:11:25: error: only `==`, `!=`, `|` and `&` are defined on `[flag]` tagged `enum`, use an explicit cast to `int` if needed + 9 | println(FilePerm.read > FilePerm.write) + 10 | println(FilePerm.write + FilePerm.exec) + 11 | println(FilePerm.write && FilePerm.exec) + | ~~ + 12 | } diff --git a/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.out b/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.out index d1b88fa9b7..caab66c255 100644 --- a/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.out +++ b/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.out @@ -5,9 +5,22 @@ vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv:9:2: error: | ^ 10 | println('a is $a') 11 | } +vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv:9:6: error: cannot assign to `a`: expected `void`, not `int literal` + 7 | fn main() { + 8 | func1() + 9 | a = 2 + | ^ + 10 | println('a is $a') + 11 | } vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv:10:17: error: undefined ident: `a` 8 | func1() 9 | a = 2 10 | println('a is $a') | ^ 11 | } +vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv:10:17: error: expression does not return a value + 8 | func1() + 9 | a = 2 + 10 | println('a is $a') + | ^ + 11 | } diff --git a/vlib/v/checker/tests/filter_on_non_arr_err.out b/vlib/v/checker/tests/filter_on_non_arr_err.out index d01f0fd2e4..b3b298da31 100644 --- a/vlib/v/checker/tests/filter_on_non_arr_err.out +++ b/vlib/v/checker/tests/filter_on_non_arr_err.out @@ -3,3 +3,8 @@ vlib/v/checker/tests/filter_on_non_arr_err.vv:2:14: error: unknown method or fie 2 | _ := 'test'.filter(it == `t`) | ~~~~~~~~~~~~~~~~~ 3 | } +vlib/v/checker/tests/filter_on_non_arr_err.vv:2:4: error: assignment mismatch: 1 variable(s) but `filter()` returns 0 value(s) + 1 | fn main() { + 2 | _ := 'test'.filter(it == `t`) + | ~~ + 3 | } diff --git a/vlib/v/checker/tests/fixed_array_conv.out b/vlib/v/checker/tests/fixed_array_conv.out index 79f961ff7c..bf6a171fe0 100644 --- a/vlib/v/checker/tests/fixed_array_conv.out +++ b/vlib/v/checker/tests/fixed_array_conv.out @@ -12,6 +12,13 @@ vlib/v/checker/tests/fixed_array_conv.vv:3:3: error: mismatched types `voidptr` | ^ 4 | mut ip := &int(0) 5 | ip = arr +vlib/v/checker/tests/fixed_array_conv.vv:3:5: error: cannot assign to `p`: expected `voidptr`, not `[2]int` + 1 | arr := [2, 3]! + 2 | mut p := unsafe { nil } + 3 | p = arr + | ~~~ + 4 | mut ip := &int(0) + 5 | ip = arr vlib/v/checker/tests/fixed_array_conv.vv:5:4: error: mismatched types `&int` and `[2]int` 3 | p = arr 4 | mut ip := &int(0) @@ -19,6 +26,13 @@ vlib/v/checker/tests/fixed_array_conv.vv:5:4: error: mismatched types `&int` and | ^ 6 | _ = &int(arr) 7 | _ = p +vlib/v/checker/tests/fixed_array_conv.vv:5:6: error: cannot assign to `ip`: expected `&int`, not `[2]int` + 3 | p = arr + 4 | mut ip := &int(0) + 5 | ip = arr + | ~~~ + 6 | _ = &int(arr) + 7 | _ = p vlib/v/checker/tests/fixed_array_conv.vv:11:13: error: cannot use `[2]int` as `voidptr` in argument 1 to `memdup` 9 | 10 | unsafe { diff --git a/vlib/v/checker/tests/fixed_array_decompose_err.out b/vlib/v/checker/tests/fixed_array_decompose_err.out index 5c4a87c89d..a188195cfa 100644 --- a/vlib/v/checker/tests/fixed_array_decompose_err.out +++ b/vlib/v/checker/tests/fixed_array_decompose_err.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/fixed_array_decompose_err.vv:11:9: error: direct decomposit 11 | sum(...arr) | ~~~ 12 | } +vlib/v/checker/tests/fixed_array_decompose_err.vv:11:6: error: `ast.ArrayDecompose` (no value) used as value in argument 1 to `sum` + 9 | fn main() { + 10 | arr := [1, 2, 3, 4]! + 11 | sum(...arr) + | ~~~~~~ + 12 | } diff --git a/vlib/v/checker/tests/fixed_array_non_const_size_err.out b/vlib/v/checker/tests/fixed_array_non_const_size_err.out index 073492085f..85bbb57edb 100644 --- a/vlib/v/checker/tests/fixed_array_non_const_size_err.out +++ b/vlib/v/checker/tests/fixed_array_non_const_size_err.out @@ -1,7 +1,14 @@ vlib/v/checker/tests/fixed_array_non_const_size_err.vv:4:12: error: non-constant array bound `size` 2 | size := 2 - 3 | + 3 | 4 | array := [size]int{} | ~~~~ - 5 | + 5 | + 6 | println(array) +vlib/v/checker/tests/fixed_array_non_const_size_err.vv:4:12: error: fixed size cannot be zero or negative (fixed_size: 0) + 2 | size := 2 + 3 | + 4 | array := [size]int{} + | ~~~~ + 5 | 6 | println(array) diff --git a/vlib/v/checker/tests/fn_call_with_extra_parenthesis.out b/vlib/v/checker/tests/fn_call_with_extra_parenthesis.out index 75449fc204..cfcb5c87f2 100644 --- a/vlib/v/checker/tests/fn_call_with_extra_parenthesis.out +++ b/vlib/v/checker/tests/fn_call_with_extra_parenthesis.out @@ -1,6 +1,12 @@ vlib/v/checker/tests/fn_call_with_extra_parenthesis.vv:5:7: error: expected 1 arguments, but got 0 - 3 | + 3 | 4 | fn main() { 5 | main.doit()(1) | ~~~~~~ 6 | } +vlib/v/checker/tests/fn_call_with_extra_parenthesis.vv:5:14: error: unknown function: + 3 | + 4 | fn main() { + 5 | main.doit()(1) + | ^ + 6 | } diff --git a/vlib/v/checker/tests/fn_init_sig.out b/vlib/v/checker/tests/fn_init_sig.out index 08cb17b952..43a45ea156 100644 --- a/vlib/v/checker/tests/fn_init_sig.out +++ b/vlib/v/checker/tests/fn_init_sig.out @@ -10,3 +10,10 @@ vlib/v/checker/tests/fn_init_sig.vv:4:1: error: fn `init` must not be public | ~~~~~~~~~~~~~~~~~ 5 | return 1 6 | } +vlib/v/checker/tests/fn_init_sig.vv:4:1: error: fn `init` cannot have a return type + 2 | return 1 + 3 | } + 4 | pub fn init() int { + | ~~~~~~~~~~~~~~~~~ + 5 | return 1 + 6 | } diff --git a/vlib/v/checker/tests/fn_param_import_sym_conflict.out b/vlib/v/checker/tests/fn_param_import_sym_conflict.out index 548101e99f..355ee576a9 100644 --- a/vlib/v/checker/tests/fn_param_import_sym_conflict.out +++ b/vlib/v/checker/tests/fn_param_import_sym_conflict.out @@ -14,10 +14,10 @@ vlib/v/checker/tests/fn_param_import_sym_conflict.vv:3:8: warning: module 'strs 2 | import maps 3 | import strings as strs | ~~~~~~~ - 4 | + 4 | 5 | // FnDecl vlib/v/checker/tests/fn_param_import_sym_conflict.vv:6:6: error: duplicate of an import symbol `arrays` - 4 | + 4 | 5 | // FnDecl 6 | fn x(arrays []int) { | ~~~~~~ @@ -25,49 +25,63 @@ vlib/v/checker/tests/fn_param_import_sym_conflict.vv:6:6: error: duplicate of an 8 | vlib/v/checker/tests/fn_param_import_sym_conflict.vv:9:1: error: duplicate of an import symbol `maps` 7 | } - 8 | + 8 | 9 | fn maps() { | ~~~~~~~~~ 10 | } 11 | vlib/v/checker/tests/fn_param_import_sym_conflict.vv:12:9: error: duplicate of an import symbol `arrays` 10 | } - 11 | + 11 | 12 | fn maps(arrays []int) { | ~~~~~~ 13 | } 14 | +vlib/v/checker/tests/fn_param_import_sym_conflict.vv:12:1: error: duplicate of an import symbol `maps` + 10 | } + 11 | + 12 | fn maps(arrays []int) { + | ~~~~~~~~~~~~~~~~~~~~~ + 13 | } + 14 | vlib/v/checker/tests/fn_param_import_sym_conflict.vv:18:1: error: duplicate of an import symbol `strs` 16 | } - 17 | + 17 | 18 | fn strs() { | ~~~~~~~~~ 19 | } 20 | vlib/v/checker/tests/fn_param_import_sym_conflict.vv:24:5: error: duplicate of an import symbol `arrays` 22 | struct Foo {} - 23 | + 23 | 24 | fn (arrays Foo) x() { | ~~~~~~ 25 | } 26 | vlib/v/checker/tests/fn_param_import_sym_conflict.vv:27:5: error: duplicate of an import symbol `arrays` 25 | } - 26 | + 26 | 27 | fn (arrays Foo) y(maps []int) { | ~~~~~~ 28 | } 29 | -vlib/v/checker/tests/fn_param_import_sym_conflict.vv:30:16: error: duplicate of an import symbol `arrays` +vlib/v/checker/tests/fn_param_import_sym_conflict.vv:27:19: error: duplicate of an import symbol `maps` + 25 | } + 26 | + 27 | fn (arrays Foo) y(maps []int) { + | ~~~~ 28 | } 29 | +vlib/v/checker/tests/fn_param_import_sym_conflict.vv:30:16: error: duplicate of an import symbol `arrays` + 28 | } + 29 | 30 | fn (foo Foo) z(arrays []int) { | ~~~~~~ 31 | } 32 | vlib/v/checker/tests/fn_param_import_sym_conflict.vv:33:5: error: duplicate of an import symbol `arrays` 31 | } - 32 | + 32 | 33 | fn (arrays Foo) maps() { | ~~~~~~ 34 | } @@ -77,4 +91,4 @@ vlib/v/checker/tests/fn_param_import_sym_conflict.vv:47:11: error: duplicate of 46 | fn y() { 47 | _ := fn (arrays []int) {} | ~~~~~~ - 48 | } \ No newline at end of file + 48 | } diff --git a/vlib/v/checker/tests/fn_type_exists.out b/vlib/v/checker/tests/fn_type_exists.out index c6aa40fcc0..46348bb6fa 100644 --- a/vlib/v/checker/tests/fn_type_exists.out +++ b/vlib/v/checker/tests/fn_type_exists.out @@ -1,10 +1,15 @@ vlib/v/checker/tests/fn_type_exists.vv:1:34: error: unknown type `Pants` 1 | type PantsCreator = fn (a Shirt) Pants | ~~~~~ - 2 | + 2 | + 3 | type PantsConsumer = fn (p Pants) +vlib/v/checker/tests/fn_type_exists.vv:1:27: error: unknown type `Shirt` + 1 | type PantsCreator = fn (a Shirt) Pants + | ~~~~~ + 2 | 3 | type PantsConsumer = fn (p Pants) vlib/v/checker/tests/fn_type_exists.vv:3:28: error: unknown type `Pants` 1 | type PantsCreator = fn (a Shirt) Pants - 2 | + 2 | 3 | type PantsConsumer = fn (p Pants) - | ~~~~~ \ No newline at end of file + | ~~~~~ diff --git a/vlib/v/checker/tests/fn_type_mismatch.out b/vlib/v/checker/tests/fn_type_mismatch.out index 922c19abcf..a9a71f0a69 100644 --- a/vlib/v/checker/tests/fn_type_mismatch.out +++ b/vlib/v/checker/tests/fn_type_mismatch.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/fn_type_mismatch.vv:11:15: error: invalid array element: expected `fn (int, int) f32`, not `fn (f32, f32) f32` - 9 | + 9 | 10 | fn main() { 11 | fns := [add, div] | ~~~ @@ -12,9 +12,22 @@ vlib/v/checker/tests/fn_type_mismatch.vv:12:17: error: cannot use `float literal | ~~~~ 13 | println(fns[1](10.0, 5.0)) 14 | } +vlib/v/checker/tests/fn_type_mismatch.vv:12:23: error: cannot use `float literal` as `int` in argument 2 to `` + 10 | fn main() { + 11 | fns := [add, div] + 12 | println(fns[0](10.0, 5.0)) + | ~~~ + 13 | println(fns[1](10.0, 5.0)) + 14 | } vlib/v/checker/tests/fn_type_mismatch.vv:13:17: error: cannot use `float literal` as `int` in argument 1 to `` 11 | fns := [add, div] 12 | println(fns[0](10.0, 5.0)) 13 | println(fns[1](10.0, 5.0)) | ~~~~ 14 | } +vlib/v/checker/tests/fn_type_mismatch.vv:13:23: error: cannot use `float literal` as `int` in argument 2 to `` + 11 | fns := [add, div] + 12 | println(fns[0](10.0, 5.0)) + 13 | println(fns[1](10.0, 5.0)) + | ~~~ + 14 | } diff --git a/vlib/v/checker/tests/fn_var.out b/vlib/v/checker/tests/fn_var.out index be5cf19f41..93b67786eb 100644 --- a/vlib/v/checker/tests/fn_var.out +++ b/vlib/v/checker/tests/fn_var.out @@ -22,6 +22,12 @@ vlib/v/checker/tests/fn_var.vv:9:10: error: undefined ident: `i` 9 | println(i) | ^ 10 | } +vlib/v/checker/tests/fn_var.vv:9:2: error: `println` can not print void expressions + 7 | println(i) + 8 | f = fn (mut a []int) { + 9 | println(i) + | ~~~~~~~~~~ + 10 | } vlib/v/checker/tests/fn_var.vv:8:5: error: cannot assign to `f`: expected `fn (int) u8`, not `fn (mut []int)` 6 | i := 0 7 | println(i) diff --git a/vlib/v/checker/tests/for_in_invalid_identifier.out b/vlib/v/checker/tests/for_in_invalid_identifier.out index 79115d7d71..89c30146ef 100644 --- a/vlib/v/checker/tests/for_in_invalid_identifier.out +++ b/vlib/v/checker/tests/for_in_invalid_identifier.out @@ -4,10 +4,16 @@ vlib/v/checker/tests/for_in_invalid_identifier.vv:2:26: error: undefined ident: | ^ 3 | println('Hello $index $value') 4 | } +vlib/v/checker/tests/for_in_invalid_identifier.vv:2:28: error: `s` does not return a value + 1 | fn main() { + 2 | for index, mut value in s.statements { + | ~~~~~~~~~~ + 3 | println('Hello $index $value') + 4 | } vlib/v/checker/tests/for_in_invalid_identifier.vv:3:26: error: no known default format for type `void` 1 | fn main() { 2 | for index, mut value in s.statements { 3 | println('Hello $index $value') | ~~~~~ 4 | } - 5 | } \ No newline at end of file + 5 | } diff --git a/vlib/v/checker/tests/free_method_errors.out b/vlib/v/checker/tests/free_method_errors.out index 2b3376d031..20dfce3aa5 100644 --- a/vlib/v/checker/tests/free_method_errors.out +++ b/vlib/v/checker/tests/free_method_errors.out @@ -12,6 +12,13 @@ vlib/v/checker/tests/free_method_errors.vv:7:23: error: `.free()` methods should | ~~~ 8 | 9 | struct Error3 {} +vlib/v/checker/tests/free_method_errors.vv:7:1: error: missing return at end of function `free` + 5 | struct Error2 {} + 6 | + 7 | fn (a &Error2) free() f64 {} + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + 8 | + 9 | struct Error3 {} vlib/v/checker/tests/free_method_errors.vv:11:1: error: `.free()` methods should have 0 arguments 9 | struct Error3 {} 10 | diff --git a/vlib/v/checker/tests/generic_closure_fn_decl_err_b.out b/vlib/v/checker/tests/generic_closure_fn_decl_err_b.out index 807e4bba7a..7918f0165e 100644 --- a/vlib/v/checker/tests/generic_closure_fn_decl_err_b.out +++ b/vlib/v/checker/tests/generic_closure_fn_decl_err_b.out @@ -1,7 +1,14 @@ vlib/v/checker/tests/generic_closure_fn_decl_err_b.vv:13:2: error: generic closure fn must specify type parameter, e.g. fn [foo] [T]() 11 | println(typeof(my_plugin).name) // MyPlugin - 12 | + 12 | 13 | fn[my_plugin](){ my_plugin.on_update() }() | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 | } 15 | +vlib/v/checker/tests/generic_closure_fn_decl_err_b.vv:13:29: error: unknown method or field: `T.on_update` + 11 | println(typeof(my_plugin).name) // MyPlugin + 12 | + 13 | fn[my_plugin](){ my_plugin.on_update() }() + | ~~~~~~~~~~~ + 14 | } + 15 | diff --git a/vlib/v/checker/tests/generic_fn_decl_err.out b/vlib/v/checker/tests/generic_fn_decl_err.out index bd331c0157..45f5fbbfb8 100644 --- a/vlib/v/checker/tests/generic_fn_decl_err.out +++ b/vlib/v/checker/tests/generic_fn_decl_err.out @@ -1,34 +1,34 @@ vlib/v/checker/tests/generic_fn_decl_err.vv:19:29: error: generic type name `P` is not mentioned in fn `create1[U]` 17 | } - 18 | + 18 | 19 | fn (r Db) create1(u U, p P) { | ^ 20 | println('Yo') 21 | } vlib/v/checker/tests/generic_fn_decl_err.vv:23:29: error: generic type name `P` is not mentioned in fn `create2[U]` 21 | } - 22 | + 22 | 23 | fn (r Db) create2(u U, p &P) { | ~~ 24 | println('Yo') 25 | } vlib/v/checker/tests/generic_fn_decl_err.vv:27:29: error: generic type name `P` is not mentioned in fn `create3[U]` 25 | } - 26 | + 26 | 27 | fn (r Db) create3(u U, p []P) { | ~~~ 28 | println('Yo') 29 | } vlib/v/checker/tests/generic_fn_decl_err.vv:31:27: error: generic type name `P` is not mentioned in fn `create4[U]` 29 | } - 30 | + 30 | 31 | fn (r Db) create4(u U) P { | ^ 32 | return P{} 33 | } vlib/v/checker/tests/generic_fn_decl_err.vv:35:27: error: generic type name `P` is not mentioned in fn `create5[U]` 33 | } - 34 | + 34 | 35 | fn (r Db) create5(u U) []P { | ~~~ 36 | return [P{}] diff --git a/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.out b/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.out index 40eeb22218..95eec22236 100644 --- a/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.out +++ b/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.out @@ -1,24 +1,45 @@ vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:26:1: error: generic function declaration must specify generic type names 24 | } - 25 | + 25 | 26 | fn g_worker(g Generic[T]) { | ~~~~~~~~~~~~~~~~~~~~~~~~~ 27 | t := <-g.ch 28 | handle(t) Details: use `fn foo[T](x T) {`, not just `fn foo(x T) {` +vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:26:15: error: generic type name `T` is not mentioned in fn `g_worker[]` + 24 | } + 25 | + 26 | fn g_worker(g Generic[T]) { + | ~~~~~~~~~~ + 27 | t := <-g.ch + 28 | handle(t) vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:32:1: error: generic function declaration must specify generic type names 30 | } - 31 | + 31 | 32 | fn handle(t T) { | ~~~~~~~~~~~~~~ 33 | println('hi') 34 | } Details: use `fn foo[T](x T) {`, not just `fn foo(x T) {` +vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:32:13: error: generic type name `T` is not mentioned in fn `handle[]` + 30 | } + 31 | + 32 | fn handle(t T) { + | ^ + 33 | println('hi') + 34 | } vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:40:1: error: generic method declaration must specify generic type names 38 | type MayBe[T] = None | T - 39 | + 39 | 40 | fn (m MayBe[T]) is_some() bool { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41 | return m is T 42 | } Details: use `fn (r SomeType[T]) foo[T]() {`, not just `fn (r SomeType[T]) foo() {` +vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:40:7: error: generic type name `T` is not mentioned in fn `is_some[]` + 38 | type MayBe[T] = None | T + 39 | + 40 | fn (m MayBe[T]) is_some() bool { + | ~~~~~~~~ + 41 | return m is T + 42 | } diff --git a/vlib/v/checker/tests/generic_interface_err.out b/vlib/v/checker/tests/generic_interface_err.out index 007bc890f7..10030574f5 100644 --- a/vlib/v/checker/tests/generic_interface_err.out +++ b/vlib/v/checker/tests/generic_interface_err.out @@ -1,16 +1,21 @@ vlib/v/checker/tests/generic_interface_err.vv:10:1: warning: unused variable: `i` - 8 | + 8 | 9 | s := Struct{7} 10 | i := Interface(s) | ^ vlib/v/checker/tests/generic_interface_err.vv:9:6: error: could not infer generic type `T` in generic struct `Struct[T]` 7 | } - 8 | + 8 | 9 | s := Struct{7} | ~~~~~~~~~ 10 | i := Interface(s) vlib/v/checker/tests/generic_interface_err.vv:10:6: error: can not find method `method` on `Struct`, needed for interface: `Interface` - 8 | + 8 | + 9 | s := Struct{7} + 10 | i := Interface(s) + | ~~~~~~~~~~~~ +vlib/v/checker/tests/generic_interface_err.vv:10:6: error: `Struct` does not implement interface `Interface`, cannot cast `Struct` to interface `Interface` + 8 | 9 | s := Struct{7} 10 | i := Interface(s) | ~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/generic_sumtype_decl_err_a.out b/vlib/v/checker/tests/generic_sumtype_decl_err_a.out index 368b71042b..b828c26b07 100644 --- a/vlib/v/checker/tests/generic_sumtype_decl_err_a.out +++ b/vlib/v/checker/tests/generic_sumtype_decl_err_a.out @@ -1,7 +1,14 @@ vlib/v/checker/tests/generic_sumtype_decl_err_a.vv:7:24: error: generic struct `Just` must specify generic type names, e.g. Just[T] 5 | struct Nothing {} - 6 | + 6 | 7 | type Maybe = Nothing | Just | ~~~~ - 8 | + 8 | + 9 | fn main() { +vlib/v/checker/tests/generic_sumtype_decl_err_a.vv:7:6: error: generic sumtype `Maybe` must specify generic type names, e.g. Maybe[T] + 5 | struct Nothing {} + 6 | + 7 | type Maybe = Nothing | Just + | ~~~~~ + 8 | 9 | fn main() { diff --git a/vlib/v/checker/tests/generic_sumtype_decl_err_d.out b/vlib/v/checker/tests/generic_sumtype_decl_err_d.out index a748a26e06..8489cf74f1 100644 --- a/vlib/v/checker/tests/generic_sumtype_decl_err_d.out +++ b/vlib/v/checker/tests/generic_sumtype_decl_err_d.out @@ -1,7 +1,14 @@ vlib/v/checker/tests/generic_sumtype_decl_err_d.vv:5:15: error: generic fntype `Fn` must specify generic type names, e.g. Fn[T] 3 | type Fnn = fn (string) string - 4 | + 4 | 5 | type Parser = Fn | Fnn | ~~ - 6 | + 6 | + 7 | fn main() { +vlib/v/checker/tests/generic_sumtype_decl_err_d.vv:5:6: error: generic sumtype `Parser` must specify generic type names, e.g. Parser[T] + 3 | type Fnn = fn (string) string + 4 | + 5 | type Parser = Fn | Fnn + | ~~~~~~ + 6 | 7 | fn main() { diff --git a/vlib/v/checker/tests/generic_type_name_in_non_generic_function.out b/vlib/v/checker/tests/generic_type_name_in_non_generic_function.out index c4db510710..fa68c3c999 100644 --- a/vlib/v/checker/tests/generic_type_name_in_non_generic_function.out +++ b/vlib/v/checker/tests/generic_type_name_in_non_generic_function.out @@ -5,3 +5,31 @@ vlib/v/checker/tests/generic_type_name_in_non_generic_function.vv:3:10: error: u | ^ 4 | println('yes') 5 | } else { +vlib/v/checker/tests/generic_type_name_in_non_generic_function.vv:3:20: error: undefined ident: `Z` + 1 | fn main() { + 2 | c := u8(`D`) + 3 | if c >= A && c <= Z { + | ^ + 4 | println('yes') + 5 | } else { +vlib/v/checker/tests/generic_type_name_in_non_generic_function.vv:3:5: error: left operand for `&&` is not a boolean + 1 | fn main() { + 2 | c := u8(`D`) + 3 | if c >= A && c <= Z { + | ~~~~~~ + 4 | println('yes') + 5 | } else { +vlib/v/checker/tests/generic_type_name_in_non_generic_function.vv:3:15: error: right operand for `&&` is not a boolean + 1 | fn main() { + 2 | c := u8(`D`) + 3 | if c >= A && c <= Z { + | ~~~~~~ + 4 | println('yes') + 5 | } else { +vlib/v/checker/tests/generic_type_name_in_non_generic_function.vv:3:5: error: non-bool type `void` used as if condition + 1 | fn main() { + 2 | c := u8(`D`) + 3 | if c >= A && c <= Z { + | ~~~~~~~~~~~~~~~~ + 4 | println('yes') + 5 | } else { diff --git a/vlib/v/checker/tests/generics_fn_arguments_count_err.out b/vlib/v/checker/tests/generics_fn_arguments_count_err.out index 62cb366698..752bd5dbdb 100644 --- a/vlib/v/checker/tests/generics_fn_arguments_count_err.out +++ b/vlib/v/checker/tests/generics_fn_arguments_count_err.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/generics_fn_arguments_count_err.vv:12:18: error: expected 2 generic parameters, got 1 - 10 | + 10 | 11 | fn main() { 12 | ret1 := get_name(11, 22) | ~~~~~ @@ -7,13 +7,20 @@ vlib/v/checker/tests/generics_fn_arguments_count_err.vv:12:18: error: expected 2 14 | vlib/v/checker/tests/generics_fn_arguments_count_err.vv:15:18: error: expected 2 generic parameters, got 3 13 | println(ret1) - 14 | + 14 | 15 | ret2 := get_name(11, 22, 'hello') | ~~~~~~~~~~~~~~~~~~ 16 | println(ret2) 17 | -vlib/v/checker/tests/generics_fn_arguments_count_err.vv:19:22: error: expected 2 generic parameters, got 1 +vlib/v/checker/tests/generics_fn_arguments_count_err.vv:15:45: error: expected 2 arguments, but got 3 + 13 | println(ret1) + 14 | + 15 | ret2 := get_name(11, 22, 'hello') + | ~~~~~~~ + 16 | println(ret2) 17 | +vlib/v/checker/tests/generics_fn_arguments_count_err.vv:19:22: error: expected 2 generic parameters, got 1 + 17 | 18 | foo := Foo{} 19 | ret3 := foo.get_name(11, 22) | ~~~~~ @@ -21,21 +28,41 @@ vlib/v/checker/tests/generics_fn_arguments_count_err.vv:19:22: error: expected 2 21 | vlib/v/checker/tests/generics_fn_arguments_count_err.vv:22:22: error: expected 2 generic parameters, got 3 20 | println(ret3) - 21 | + 21 | 22 | ret4 := foo.get_name(11, 22, 'hello') | ~~~~~~~~~~~~~~~~~~ 23 | println(ret4) 24 | } +vlib/v/checker/tests/generics_fn_arguments_count_err.vv:22:49: error: expected 2 arguments, but got 3 + 20 | println(ret3) + 21 | + 22 | ret4 := foo.get_name(11, 22, 'hello') + | ~~~~~~~ + 23 | println(ret4) + 24 | } vlib/v/checker/tests/generics_fn_arguments_count_err.vv:2:11: error: no known default format for type `A` 1 | fn get_name(a A, b B) string { 2 | return '$a, $b' | ^ 3 | } 4 | +vlib/v/checker/tests/generics_fn_arguments_count_err.vv:2:15: error: no known default format for type `B` + 1 | fn get_name(a A, b B) string { + 2 | return '$a, $b' + | ^ + 3 | } + 4 | vlib/v/checker/tests/generics_fn_arguments_count_err.vv:8:11: error: no known default format for type `A` - 6 | + 6 | 7 | fn (f Foo) get_name(a A, b B) string { 8 | return '$a, $b' | ^ 9 | } 10 | +vlib/v/checker/tests/generics_fn_arguments_count_err.vv:8:15: error: no known default format for type `B` + 6 | + 7 | fn (f Foo) get_name(a A, b B) string { + 8 | return '$a, $b' + | ^ + 9 | } + 10 | diff --git a/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out b/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out index 47cb85524e..c7508524a0 100644 --- a/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out +++ b/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out @@ -1,12 +1,12 @@ vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv:13:32: error: return generic struct `GenericChannelStruct` in fn declaration must specify the generic type names, e.g. GenericChannelStruct[T] 11 | } - 12 | + 12 | 13 | pub fn new_channel_struct[T]() GenericChannelStruct { | ~~~~~~~~~~~~~~~~~~~~ 14 | d := GenericChannelStruct{ 15 | ch: chan T{} vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv:14:7: error: generic struct init must specify type parameter, e.g. Foo[T] - 12 | + 12 | 13 | pub fn new_channel_struct[T]() GenericChannelStruct { 14 | d := GenericChannelStruct{ | ~~~~~~~~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/generics_struct_init_err.out b/vlib/v/checker/tests/generics_struct_init_err.out index 9fab5e57bf..a729f888c4 100644 --- a/vlib/v/checker/tests/generics_struct_init_err.out +++ b/vlib/v/checker/tests/generics_struct_init_err.out @@ -19,6 +19,13 @@ vlib/v/checker/tests/generics_struct_init_err.vv:67:8: error: could not infer ge | ~~~~~~~~~~~~~~ 68 | assert ret == -6 69 | } +vlib/v/checker/tests/generics_struct_init_err.vv:67:23: error: could not infer generic type `T` in call to `call` + 65 | ret = holder_call_22(neg, 5) + 66 | assert ret == -5 + 67 | ret = FnHolder2{neg}.call(6) + | ~~~~~~~ + 68 | assert ret == -6 + 69 | } vlib/v/checker/tests/generics_struct_init_err.vv:22:7: error: generic struct init must specify type parameter, e.g. Foo[T] 20 | 21 | fn holder_call_1[T](func T, a int) int { diff --git a/vlib/v/checker/tests/generics_struct_init_type_parameter_err.out b/vlib/v/checker/tests/generics_struct_init_type_parameter_err.out index 269e14d0c3..9076777f51 100644 --- a/vlib/v/checker/tests/generics_struct_init_type_parameter_err.out +++ b/vlib/v/checker/tests/generics_struct_init_type_parameter_err.out @@ -1,12 +1,12 @@ vlib/v/checker/tests/generics_struct_init_type_parameter_err.vv:6:9: error: generic struct init type parameter `U` must be within the parameters `(A,B)` of the current generic function - 4 | + 4 | 5 | fn send_1(res A, b B) string { 6 | msg := Response{ | ~~~~~~~~~~~~ 7 | result: res 8 | } vlib/v/checker/tests/generics_struct_init_type_parameter_err.vv:14:9: error: generic struct init expects 1 generic parameter, but got 2 - 12 | + 12 | 13 | fn send_2(res A, b B) string { 14 | msg := Response{ | ~~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/go_wait_or.out b/vlib/v/checker/tests/go_wait_or.out index 55372c8dac..769a8d0119 100644 --- a/vlib/v/checker/tests/go_wait_or.out +++ b/vlib/v/checker/tests/go_wait_or.out @@ -33,6 +33,13 @@ vlib/v/checker/tests/go_wait_or.vv:25:6: error: `.wait()` cannot be called for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 26 | for t in tg3 { 27 | a := t.wait() +vlib/v/checker/tests/go_wait_or.vv:25:13: error: unexpected `or` block, the function `wait` does not return an Option or a Result + 23 | spawn f(1) + 24 | ] + 25 | tg3.wait() or { panic('problem') } + | ~~~~~~~~~~~~~~~~~~~~~~~ + 26 | for t in tg3 { + 27 | a := t.wait() vlib/v/checker/tests/go_wait_or.vv:38:6: error: `.wait()` cannot be called for an array when thread functions return options. Iterate over the arrays elements instead and handle each returned option with `or`. 36 | spawn g(1) 37 | ] diff --git a/vlib/v/checker/tests/goto_label.out b/vlib/v/checker/tests/goto_label.out index 985b6889a6..b4a0bf4ad7 100644 --- a/vlib/v/checker/tests/goto_label.out +++ b/vlib/v/checker/tests/goto_label.out @@ -1,77 +1,77 @@ -vlib/v/checker/tests/goto_label.vv:7:8: warning: `goto` requires `unsafe` (consider using labelled break/continue) - 5 | goto a1 - 6 | _ = fn(){ - 7 | goto f1 +vlib/v/checker/tests/goto_label.vv:8:9: warning: `goto` requires `unsafe` (consider using labelled break/continue) + 6 | goto a1 + 7 | _ = fn () { + 8 | goto f1 // the `f1` label is not available here; it is in the outer scope + | ~~ + 9 | goto f2 // same with `f2` + 10 | goto a1 // this is ok +vlib/v/checker/tests/goto_label.vv:9:9: warning: `goto` requires `unsafe` (consider using labelled break/continue) + 7 | _ = fn () { + 8 | goto f1 // the `f1` label is not available here; it is in the outer scope + 9 | goto f2 // same with `f2` + | ~~ + 10 | goto a1 // this is ok + 11 | a1: +vlib/v/checker/tests/goto_label.vv:10:9: warning: `goto` requires `unsafe` (consider using labelled break/continue) + 8 | goto f1 // the `f1` label is not available here; it is in the outer scope + 9 | goto f2 // same with `f2` + 10 | goto a1 // this is ok + | ~~ + 11 | a1: + 12 | goto a1 +vlib/v/checker/tests/goto_label.vv:12:9: warning: `goto` requires `unsafe` (consider using labelled break/continue) + 10 | goto a1 // this is ok + 11 | a1: + 12 | goto a1 + | ~~ + 13 | } + 14 | f2: +vlib/v/checker/tests/goto_label.vv:6:8: error: unknown label `a1` + 4 | goto f2 + 5 | f1: + 6 | goto a1 | ~~ - 8 | goto f2 - 9 | goto a1 -vlib/v/checker/tests/goto_label.vv:8:8: warning: `goto` requires `unsafe` (consider using labelled break/continue) - 6 | _ = fn(){ - 7 | goto f1 - 8 | goto f2 + 7 | _ = fn () { + 8 | goto f1 // the `f1` label is not available here; it is in the outer scope +vlib/v/checker/tests/goto_label.vv:8:9: error: unknown label `f1` + 6 | goto a1 + 7 | _ = fn () { + 8 | goto f1 // the `f1` label is not available here; it is in the outer scope + | ~~ + 9 | goto f2 // same with `f2` + 10 | goto a1 // this is ok +vlib/v/checker/tests/goto_label.vv:9:9: error: unknown label `f2` + 7 | _ = fn () { + 8 | goto f1 // the `f1` label is not available here; it is in the outer scope + 9 | goto f2 // same with `f2` + | ~~ + 10 | goto a1 // this is ok + 11 | a1: +vlib/v/checker/tests/goto_label.vv:15:8: error: unknown label `a1` + 13 | } + 14 | f2: + 15 | goto a1 | ~~ - 9 | goto a1 - 10 | a1: -vlib/v/checker/tests/goto_label.vv:9:8: warning: `goto` requires `unsafe` (consider using labelled break/continue) - 7 | goto f1 - 8 | goto f2 - 9 | goto a1 + 16 | goto f1 // back + 17 | goto f2 +vlib/v/checker/tests/goto_label.vv:25:8: error: unknown label `f1` + 23 | goto g1 // forward + 24 | g1: + 25 | goto f1 | ~~ - 10 | a1: - 11 | goto a1 -vlib/v/checker/tests/goto_label.vv:11:8: warning: `goto` requires `unsafe` (consider using labelled break/continue) - 9 | goto a1 - 10 | a1: - 11 | goto a1 + 26 | goto a1 + 27 | goto g1 // back +vlib/v/checker/tests/goto_label.vv:26:8: error: unknown label `a1` + 24 | g1: + 25 | goto f1 + 26 | goto a1 | ~~ - 12 | } - 13 | f2: -vlib/v/checker/tests/goto_label.vv:5:7: error: unknown label `a1` - 3 | goto f2 - 4 | f1: - 5 | goto a1 - | ~~ - 6 | _ = fn(){ - 7 | goto f1 -vlib/v/checker/tests/goto_label.vv:7:8: error: unknown label `f1` - 5 | goto a1 - 6 | _ = fn(){ - 7 | goto f1 - | ~~ - 8 | goto f2 - 9 | goto a1 -vlib/v/checker/tests/goto_label.vv:8:8: error: unknown label `f2` - 6 | _ = fn(){ - 7 | goto f1 - 8 | goto f2 - | ~~ - 9 | goto a1 - 10 | a1: -vlib/v/checker/tests/goto_label.vv:14:7: error: unknown label `a1` - 12 | } - 13 | f2: - 14 | goto a1 - | ~~ - 15 | goto f1 // back - 16 | goto f2 -vlib/v/checker/tests/goto_label.vv:22:7: error: unknown label `f1` - 20 | goto g1 // forward - 21 | g1: - 22 | goto f1 - | ~~ - 23 | goto a1 - 24 | goto g1 // back -vlib/v/checker/tests/goto_label.vv:23:7: error: unknown label `a1` - 21 | g1: - 22 | goto f1 - 23 | goto a1 - | ~~ - 24 | goto g1 // back - 25 | goto undefined -vlib/v/checker/tests/goto_label.vv:25:7: error: unknown label `undefined` - 23 | goto a1 - 24 | goto g1 // back - 25 | goto undefined - | ~~~~~~~~~ - 26 | }} - 27 | + 27 | goto g1 // back + 28 | goto undefined +vlib/v/checker/tests/goto_label.vv:28:8: error: unknown label `undefined` + 26 | goto a1 + 27 | goto g1 // back + 28 | goto undefined + | ~~~~~~~~~ + 29 | } + 30 | } diff --git a/vlib/v/checker/tests/goto_label.vv b/vlib/v/checker/tests/goto_label.vv index 23b2cd75a7..8132250ad7 100644 --- a/vlib/v/checker/tests/goto_label.vv +++ b/vlib/v/checker/tests/goto_label.vv @@ -1,29 +1,33 @@ -fn f() {unsafe { - goto f1 // forward - goto f2 - f1: - goto a1 - _ = fn(){ - goto f1 +fn f() { + unsafe { + goto f1 // forward goto f2 + f1: goto a1 - a1: + _ = fn () { + goto f1 // the `f1` label is not available here; it is in the outer scope + goto f2 // same with `f2` + goto a1 // this is ok + a1: + goto a1 + } + f2: goto a1 + goto f1 // back + goto f2 } - f2: - goto a1 - goto f1 // back - goto f2 -}} +} -fn g() {unsafe { - goto g1 // forward - g1: - goto f1 - goto a1 - goto g1 // back - goto undefined -}} +fn g() { + unsafe { + goto g1 // forward + g1: + goto f1 + goto a1 + goto g1 // back + goto undefined + } +} // implicit main unsafe { diff --git a/vlib/v/checker/tests/if_match_result.out b/vlib/v/checker/tests/if_match_result.out index 00c41ad1ee..d9950d4256 100644 --- a/vlib/v/checker/tests/if_match_result.out +++ b/vlib/v/checker/tests/if_match_result.out @@ -18,6 +18,13 @@ vlib/v/checker/tests/if_match_result.vv:7:3: error: `if` expression requires an | ~~~~ 8 | } 9 | +vlib/v/checker/tests/if_match_result.vv:6:3: error: assignment mismatch: 1 variable(s) 0 value(s) + 4 | else {} + 5 | } + 6 | _ = if true { + | ^ + 7 | } else { + 8 | } vlib/v/checker/tests/if_match_result.vv:11:3: error: assignment mismatch: 1 variable(s) 0 value(s) 9 | 10 | // void results diff --git a/vlib/v/checker/tests/immutable_field.out b/vlib/v/checker/tests/immutable_field.out index 05b62143f5..99dab99a55 100644 --- a/vlib/v/checker/tests/immutable_field.out +++ b/vlib/v/checker/tests/immutable_field.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/immutable_field.vv:8:4: error: field `i1` of struct `Aaa` i 8 | a.i1 = 2 | ~~ 9 | } +vlib/v/checker/tests/immutable_field.vv:8:2: error: `a` is immutable, declare it with `mut` to make it mutable + 6 | fn main() { + 7 | a := Aaa{1} + 8 | a.i1 = 2 + | ^ + 9 | } diff --git a/vlib/v/checker/tests/import_mod_duplicate_err.out b/vlib/v/checker/tests/import_mod_duplicate_err.out index 212aed5530..74276419eb 100644 --- a/vlib/v/checker/tests/import_mod_duplicate_err.out +++ b/vlib/v/checker/tests/import_mod_duplicate_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/import_mod_duplicate_err.vv:3:8: error: cannot import `json | ~~~~ 4 | 5 | const used = true +vlib/v/checker/tests/import_mod_duplicate_err.vv:3:8: error: cannot import `json` as `json` into a module with the same name + 1 | module json + 2 | + 3 | import json + | ~~~~ + 4 | + 5 | const used = true vlib/v/checker/tests/import_mod_duplicate_err.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) 1 | module json | ^ diff --git a/vlib/v/checker/tests/import_mod_sub_duplicate_err.out b/vlib/v/checker/tests/import_mod_sub_duplicate_err.out index 735cd71abc..5c9164c34e 100644 --- a/vlib/v/checker/tests/import_mod_sub_duplicate_err.out +++ b/vlib/v/checker/tests/import_mod_sub_duplicate_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/import_mod_sub_duplicate_err.vv:3:8: error: cannot import ` | ~~~~~~~ 4 | 5 | println(json2.Any(json2.null)) +vlib/v/checker/tests/import_mod_sub_duplicate_err.vv:3:10: error: cannot import `x.json2` as `json2` into a module with the same name + 1 | module json2 + 2 | + 3 | import x.json2 + | ~~~~~ + 4 | + 5 | println(json2.Any(json2.null)) vlib/v/checker/tests/import_mod_sub_duplicate_err.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) 1 | module json2 | ^ diff --git a/vlib/v/checker/tests/import_symbol_private_err.out b/vlib/v/checker/tests/import_symbol_private_err.out index 61b570c6d1..91ad47b3a9 100644 --- a/vlib/v/checker/tests/import_symbol_private_err.out +++ b/vlib/v/checker/tests/import_symbol_private_err.out @@ -58,3 +58,9 @@ vlib/v/checker/tests/import_symbol_private_err.vv:13:6: error: struct `io.Reader 13 | _ = ReaderWriterImpl{} | ~~~~~~~~~~~~~~~~~~ 14 | } +vlib/v/checker/tests/import_symbol_private_err.vv:13:6: error: type `io.ReaderWriterImpl` is private + 11 | 'h': 2 + 12 | }.exists('h') + 13 | _ = ReaderWriterImpl{} + | ~~~~~~~~~~~~~~~~~~ + 14 | } diff --git a/vlib/v/checker/tests/import_symbol_type_err.out b/vlib/v/checker/tests/import_symbol_type_err.out index 2c1cd9be8c..3da58eaa9a 100644 --- a/vlib/v/checker/tests/import_symbol_type_err.out +++ b/vlib/v/checker/tests/import_symbol_type_err.out @@ -10,3 +10,15 @@ Did you mean `crypto.Hash`? 3 | println(Coin{}) | ~~~~~~ 4 | } +vlib/v/checker/tests/import_symbol_type_err.vv:3:11: error: unknown struct: crypto.Coin + 1 | import crypto { Coin } + 2 | fn main() { + 3 | println(Coin{}) + | ~~~~~~ + 4 | } +vlib/v/checker/tests/import_symbol_type_err.vv:3:3: error: `println` can not print void expressions + 1 | import crypto { Coin } + 2 | fn main() { + 3 | println(Coin{}) + | ~~~~~~~~~~~~~~~ + 4 | } diff --git a/vlib/v/checker/tests/incorrect_name_module.out b/vlib/v/checker/tests/incorrect_name_module.out index 5e27858511..1ca2c466bd 100644 --- a/vlib/v/checker/tests/incorrect_name_module.out +++ b/vlib/v/checker/tests/incorrect_name_module.out @@ -8,3 +8,13 @@ vlib/v/checker/tests/incorrect_name_module.vv:1:1: error: module name `_A` canno | ~~~~~~~~~ 2 | 3 | import math as _ +vlib/v/checker/tests/incorrect_name_module.vv:1:1: error: module name `_A` cannot contain uppercase letters, use snake_case instead + 1 | module _A + | ~~~~~~~~~ + 2 | + 3 | import math as _ +vlib/v/checker/tests/incorrect_name_module.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) + 1 | module _A + | ^ + 2 | + 3 | import math as _ diff --git a/vlib/v/checker/tests/incorrect_smartcast2_err.out b/vlib/v/checker/tests/incorrect_smartcast2_err.out index 804ff2fb11..aa269b2911 100644 --- a/vlib/v/checker/tests/incorrect_smartcast2_err.out +++ b/vlib/v/checker/tests/incorrect_smartcast2_err.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/incorrect_smartcast2_err.vv:24:9: notice: smartcast can only be used on the ident or selector, e.g. match foo, match foo.bar - 22 | + 22 | 23 | fn doesntwork(v []Either[int, int]) { 24 | match v[0] { | ~~~ @@ -12,3 +12,10 @@ vlib/v/checker/tests/incorrect_smartcast2_err.vv:26:17: error: field `error` doe | ~~~~~ 27 | } 28 | else {} +vlib/v/checker/tests/incorrect_smartcast2_err.vv:26:4: error: `println` can not print void expressions + 24 | match v[0] { + 25 | Left[int] { + 26 | println(v[0].error) + | ~~~~~~~~~~~~~~~~~~~ + 27 | } + 28 | else {} diff --git a/vlib/v/checker/tests/incorrect_smartcast3_err.out b/vlib/v/checker/tests/incorrect_smartcast3_err.out index 96a6471a1f..62e61a6366 100644 --- a/vlib/v/checker/tests/incorrect_smartcast3_err.out +++ b/vlib/v/checker/tests/incorrect_smartcast3_err.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/incorrect_smartcast3_err.vv:25:5: notice: smartcasting requires either an immutable value, or an explicit mut keyword before the value - 23 | + 23 | 24 | mut r := la.regex 25 | if r is RE { | ^ @@ -7,7 +7,7 @@ vlib/v/checker/tests/incorrect_smartcast3_err.vv:25:5: notice: smartcasting requ 27 | println(r.matches_string(item)) vlib/v/checker/tests/incorrect_smartcast3_err.vv:30:8: notice: smartcasting requires either an immutable value, or an explicit mut keyword before the value 28 | } - 29 | + 29 | 30 | match r { | ^ 31 | RE { r.matches_string(item) } @@ -19,8 +19,15 @@ vlib/v/checker/tests/incorrect_smartcast3_err.vv:27:13: error: unknown method or | ~~~~~~~~~~~~~~~~~~~~ 28 | } 29 | -vlib/v/checker/tests/incorrect_smartcast3_err.vv:31:10: error: unknown method or field: `OurRegex.matches_string` +vlib/v/checker/tests/incorrect_smartcast3_err.vv:27:3: error: `println` can not print void expressions + 25 | if r is RE { + 26 | println(r) + 27 | println(r.matches_string(item)) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 28 | } 29 | +vlib/v/checker/tests/incorrect_smartcast3_err.vv:31:10: error: unknown method or field: `OurRegex.matches_string` + 29 | 30 | match r { 31 | RE { r.matches_string(item) } | ~~~~~~~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/incorrect_smartcast_err.out b/vlib/v/checker/tests/incorrect_smartcast_err.out index 2f25c5cce6..8606a23831 100644 --- a/vlib/v/checker/tests/incorrect_smartcast_err.out +++ b/vlib/v/checker/tests/incorrect_smartcast_err.out @@ -19,3 +19,10 @@ vlib/v/checker/tests/incorrect_smartcast_err.vv:11:19: error: type `IExample` ha | ~~~~~ 12 | } 13 | } +vlib/v/checker/tests/incorrect_smartcast_err.vv:11:3: error: `println` can not print void expressions + 9 | mut example := IExample(Example{field:"test"}) + 10 | if example is Example{ + 11 | println(example.field) + | ~~~~~~~~~~~~~~~~~~~~~~ + 12 | } + 13 | } diff --git a/vlib/v/checker/tests/index_expr.out b/vlib/v/checker/tests/index_expr.out index 90aa0a21ea..7e65535952 100644 --- a/vlib/v/checker/tests/index_expr.out +++ b/vlib/v/checker/tests/index_expr.out @@ -67,3 +67,9 @@ vlib/v/checker/tests/index_expr.vv:20:8: error: negative index `-1` 20 | _ = a[-1..-2] | ~~ 21 | } +vlib/v/checker/tests/index_expr.vv:20:12: error: negative index `-2` + 18 | _ = a[-1..] + 19 | _ = a[..-1] + 20 | _ = a[-1..-2] + | ~~ + 21 | } diff --git a/vlib/v/checker/tests/index_invalid_call.out b/vlib/v/checker/tests/index_invalid_call.out index 34f2f7b271..5a1a4971f0 100644 --- a/vlib/v/checker/tests/index_invalid_call.out +++ b/vlib/v/checker/tests/index_invalid_call.out @@ -5,9 +5,29 @@ vlib/v/checker/tests/index_invalid_call.vv:4:20: error: cannot call the value of | ^ 5 | array := ["", "1"] 6 | array[0]() +vlib/v/checker/tests/index_invalid_call.vv:4:20: error: unknown function: + 2 | fn main() { + 3 | m := map[string]string + 4 | eprintln(m['abc']()) + | ^ + 5 | array := ["", "1"] + 6 | array[0]() +vlib/v/checker/tests/index_invalid_call.vv:4:2: error: `eprintln` can not print void expressions + 2 | fn main() { + 3 | m := map[string]string + 4 | eprintln(m['abc']()) + | ~~~~~~~~~~~~~~~~~~~~ + 5 | array := ["", "1"] + 6 | array[0]() vlib/v/checker/tests/index_invalid_call.vv:6:11: error: cannot call the element of the array, it is not a function 4 | eprintln(m['abc']()) 5 | array := ["", "1"] 6 | array[0]() | ^ 7 | } +vlib/v/checker/tests/index_invalid_call.vv:6:11: error: unknown function: + 4 | eprintln(m['abc']()) + 5 | array := ["", "1"] + 6 | array[0]() + | ^ + 7 | } diff --git a/vlib/v/checker/tests/infix_compare_option_err.out b/vlib/v/checker/tests/infix_compare_option_err.out index ecaa3f6ddc..64be235910 100644 --- a/vlib/v/checker/tests/infix_compare_option_err.out +++ b/vlib/v/checker/tests/infix_compare_option_err.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/infix_compare_option_err.vv:6:5: error: unwrapped Option ca | ~~~~~ 7 | } 8 | } +vlib/v/checker/tests/infix_compare_option_err.vv:6:5: error: unwrapped Option cannot be used in an infix expression + 4 | + 5 | fn main() { + 6 | if foo() > foo() { + | ~~~~~ + 7 | } + 8 | } diff --git a/vlib/v/checker/tests/infix_err.out b/vlib/v/checker/tests/infix_err.out index 9e05ae3e44..d8a7183e34 100644 --- a/vlib/v/checker/tests/infix_err.out +++ b/vlib/v/checker/tests/infix_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/infix_err.vv:7:5: error: mismatched types `string` and `?st | ~~~~~~~~ 8 | _ = f() + '' 9 | _ = f() + f() +vlib/v/checker/tests/infix_err.vv:7:10: error: unwrapped Option cannot be used in an infix expression + 5 | return none + 6 | } + 7 | _ = '' + f() + | ~~~ + 8 | _ = f() + '' + 9 | _ = f() + f() vlib/v/checker/tests/infix_err.vv:8:5: error: mismatched types `?string` and `string` 6 | } 7 | _ = '' + f() @@ -12,6 +19,13 @@ vlib/v/checker/tests/infix_err.vv:8:5: error: mismatched types `?string` and `st | ~~~~~~~~ 9 | _ = f() + f() 10 | +vlib/v/checker/tests/infix_err.vv:8:5: error: unwrapped Option cannot be used in an infix expression + 6 | } + 7 | _ = '' + f() + 8 | _ = f() + '' + | ~~~ + 9 | _ = f() + f() + 10 | vlib/v/checker/tests/infix_err.vv:9:9: error: `+` cannot be used with `?string` 7 | _ = '' + f() 8 | _ = f() + '' @@ -19,6 +33,13 @@ vlib/v/checker/tests/infix_err.vv:9:9: error: `+` cannot be used with `?string` | ^ 10 | 11 | _ = 4 + g() +vlib/v/checker/tests/infix_err.vv:9:5: error: unwrapped Option cannot be used in an infix expression + 7 | _ = '' + f() + 8 | _ = f() + '' + 9 | _ = f() + f() + | ~~~ + 10 | + 11 | _ = 4 + g() vlib/v/checker/tests/infix_err.vv:11:7: error: `+` cannot be used with `?int` 9 | _ = f() + f() 10 | @@ -26,6 +47,13 @@ vlib/v/checker/tests/infix_err.vv:11:7: error: `+` cannot be used with `?int` | ^ 12 | _ = int(0) + g() // FIXME not detected 13 | _ = g() + int(3) +vlib/v/checker/tests/infix_err.vv:11:9: error: unwrapped Option cannot be used in an infix expression + 9 | _ = f() + f() + 10 | + 11 | _ = 4 + g() + | ~~~ + 12 | _ = int(0) + g() // FIXME not detected + 13 | _ = g() + int(3) vlib/v/checker/tests/infix_err.vv:12:14: error: unwrapped Option cannot be used in an infix expression 10 | 11 | _ = 4 + g() @@ -40,6 +68,13 @@ vlib/v/checker/tests/infix_err.vv:13:9: error: `+` cannot be used with `?int` | ^ 14 | _ = g() + 3 15 | +vlib/v/checker/tests/infix_err.vv:13:5: error: unwrapped Option cannot be used in an infix expression + 11 | _ = 4 + g() + 12 | _ = int(0) + g() // FIXME not detected + 13 | _ = g() + int(3) + | ~~~ + 14 | _ = g() + 3 + 15 | vlib/v/checker/tests/infix_err.vv:14:9: error: `+` cannot be used with `?int` 12 | _ = int(0) + g() // FIXME not detected 13 | _ = g() + int(3) @@ -47,6 +82,13 @@ vlib/v/checker/tests/infix_err.vv:14:9: error: `+` cannot be used with `?int` | ^ 15 | 16 | // binary operands +vlib/v/checker/tests/infix_err.vv:14:5: error: unwrapped Option cannot be used in an infix expression + 12 | _ = int(0) + g() // FIXME not detected + 13 | _ = g() + int(3) + 14 | _ = g() + 3 + | ~~~ + 15 | + 16 | // binary operands vlib/v/checker/tests/infix_err.vv:17:5: error: left operand for `&&` is not a boolean 15 | 16 | // binary operands @@ -54,6 +96,13 @@ vlib/v/checker/tests/infix_err.vv:17:5: error: left operand for `&&` is not a bo | ^ 18 | _ = true || 2 19 | +vlib/v/checker/tests/infix_err.vv:17:10: error: right operand for `&&` is not a boolean + 15 | + 16 | // binary operands + 17 | _ = 1 && 2 + | ^ + 18 | _ = true || 2 + 19 | vlib/v/checker/tests/infix_err.vv:18:13: error: right operand for `||` is not a boolean 16 | // binary operands 17 | _ = 1 && 2 @@ -61,6 +110,13 @@ vlib/v/checker/tests/infix_err.vv:18:13: error: right operand for `||` is not a | ^ 19 | 20 | // boolean expressions +vlib/v/checker/tests/infix_err.vv:18:5: error: infix expr: cannot use `int literal` (right expression) as `bool` + 16 | // binary operands + 17 | _ = 1 && 2 + 18 | _ = true || 2 + | ~~~~~~~~~ + 19 | + 20 | // boolean expressions vlib/v/checker/tests/infix_err.vv:21:22: error: ambiguous boolean expression. use `()` to ensure correct order of operations 19 | 20 | // boolean expressions diff --git a/vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.out b/vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.out index 950a38f8d2..42e629c15c 100644 --- a/vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.out +++ b/vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.out @@ -6,7 +6,7 @@ vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.vv:8:14: notice: 9 | } 10 | vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.vv:12:14: notice: `int` doesn't implement method `msg` of interface `IError`. The usage of fields is being deprecated in favor of methods. - 10 | + 10 | 11 | _ = f() or { 12 | _ = err is int | ~~~ @@ -20,7 +20,7 @@ vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.vv:8:14: error: 9 | } 10 | vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.vv:12:14: error: `int` doesn't implement interface `IError` - 10 | + 10 | 11 | _ = f() or { 12 | _ = err is int | ~~~ @@ -32,3 +32,9 @@ vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.vv:27:17: error: 27 | _ := ivalue is int | ~~~ 28 | } +vlib/v/checker/tests/infix_is_notis_interface_unimplemented_err.vv:27:17: error: `int` doesn't implement interface `IAbc` + 25 | fn type_unimplemented_interface() { + 26 | ivalue := IAbc(Struct{}) + 27 | _ := ivalue is int + | ~~~ + 28 | } diff --git a/vlib/v/checker/tests/interface_generic_err.out b/vlib/v/checker/tests/interface_generic_err.out index bf888de203..697c3eabd0 100644 --- a/vlib/v/checker/tests/interface_generic_err.out +++ b/vlib/v/checker/tests/interface_generic_err.out @@ -4,7 +4,7 @@ vlib/v/checker/tests/interface_generic_err.vv:8:1: warning: unused variable: `wh 8 | why := Why(what) | ~~~ vlib/v/checker/tests/interface_generic_err.vv:7:9: error: could not infer generic type `T` in generic struct `What[T]` - 5 | + 5 | 6 | // no segfault without generic 7 | what := What{} | ~~~~~~ @@ -14,3 +14,8 @@ vlib/v/checker/tests/interface_generic_err.vv:8:8: error: could not infer generi 7 | what := What{} 8 | why := Why(what) | ~~~~~~~~~ +vlib/v/checker/tests/interface_generic_err.vv:8:8: error: `What` does not implement interface `Why`, cannot cast `What` to interface `Why` + 6 | // no segfault without generic + 7 | what := What{} + 8 | why := Why(what) + | ~~~~~~~~~ diff --git a/vlib/v/checker/tests/invalid_multi_return_operations_err.out b/vlib/v/checker/tests/invalid_multi_return_operations_err.out index 2406032379..7017ed9702 100644 --- a/vlib/v/checker/tests/invalid_multi_return_operations_err.out +++ b/vlib/v/checker/tests/invalid_multi_return_operations_err.out @@ -47,6 +47,20 @@ vlib/v/checker/tests/invalid_multi_return_operations_err.vv:11:9: error: invalid | ~~~~~~~~~~~~~~ 12 | println(foo() >> foo()) 13 | println(foo() == foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:11:9: error: invalid operation: shift on type `(int, int)` + 9 | println(foo() % foo()) + 10 | println(foo() ^ foo()) + 11 | println(foo() << foo()) + | ~~~~~ + 12 | println(foo() >> foo()) + 13 | println(foo() == foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:11:1: error: `println` can not print void expressions + 9 | println(foo() % foo()) + 10 | println(foo() ^ foo()) + 11 | println(foo() << foo()) + | ~~~~~~~~~~~~~~~~~~~~~~~ + 12 | println(foo() >> foo()) + 13 | println(foo() == foo()) vlib/v/checker/tests/invalid_multi_return_operations_err.vv:12:9: error: invalid number of operand for `>>`. Only one allowed on each side. 10 | println(foo() ^ foo()) 11 | println(foo() << foo()) @@ -54,6 +68,20 @@ vlib/v/checker/tests/invalid_multi_return_operations_err.vv:12:9: error: invalid | ~~~~~~~~~~~~~~ 13 | println(foo() == foo()) 14 | println(foo() != foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:12:9: error: invalid operation: shift on type `(int, int)` + 10 | println(foo() ^ foo()) + 11 | println(foo() << foo()) + 12 | println(foo() >> foo()) + | ~~~~~ + 13 | println(foo() == foo()) + 14 | println(foo() != foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:12:1: error: `println` can not print void expressions + 10 | println(foo() ^ foo()) + 11 | println(foo() << foo()) + 12 | println(foo() >> foo()) + | ~~~~~~~~~~~~~~~~~~~~~~~ + 13 | println(foo() == foo()) + 14 | println(foo() != foo()) vlib/v/checker/tests/invalid_multi_return_operations_err.vv:13:9: error: invalid number of operand for `==`. Only one allowed on each side. 11 | println(foo() << foo()) 12 | println(foo() >> foo()) @@ -103,6 +131,20 @@ vlib/v/checker/tests/invalid_multi_return_operations_err.vv:19:9: error: invalid | ~~~~~~~~~~~~~~ 20 | println(foo() || foo()) 21 | println(foo() in foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:19:9: error: left operand for `&&` is not a boolean + 17 | println(foo() >= foo()) + 18 | println(foo() <= foo()) + 19 | println(foo() && foo()) + | ~~~~~ + 20 | println(foo() || foo()) + 21 | println(foo() in foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:19:18: error: right operand for `&&` is not a boolean + 17 | println(foo() >= foo()) + 18 | println(foo() <= foo()) + 19 | println(foo() && foo()) + | ~~~~~ + 20 | println(foo() || foo()) + 21 | println(foo() in foo()) vlib/v/checker/tests/invalid_multi_return_operations_err.vv:20:9: error: invalid number of operand for `||`. Only one allowed on each side. 18 | println(foo() <= foo()) 19 | println(foo() && foo()) @@ -110,6 +152,20 @@ vlib/v/checker/tests/invalid_multi_return_operations_err.vv:20:9: error: invalid | ~~~~~~~~~~~~~~ 21 | println(foo() in foo()) 22 | println(foo() !in foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:20:9: error: left operand for `||` is not a boolean + 18 | println(foo() <= foo()) + 19 | println(foo() && foo()) + 20 | println(foo() || foo()) + | ~~~~~ + 21 | println(foo() in foo()) + 22 | println(foo() !in foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:20:18: error: right operand for `||` is not a boolean + 18 | println(foo() <= foo()) + 19 | println(foo() && foo()) + 20 | println(foo() || foo()) + | ~~~~~ + 21 | println(foo() in foo()) + 22 | println(foo() !in foo()) vlib/v/checker/tests/invalid_multi_return_operations_err.vv:21:9: error: invalid number of operand for `in`. Only one allowed on each side. 19 | println(foo() && foo()) 20 | println(foo() || foo()) @@ -117,6 +173,13 @@ vlib/v/checker/tests/invalid_multi_return_operations_err.vv:21:9: error: invalid | ~~~~~~~~~~~~~~ 22 | println(foo() !in foo()) 23 | println(foo() <- foo()) +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:21:15: error: `in` can only be used with arrays and maps + 19 | println(foo() && foo()) + 20 | println(foo() || foo()) + 21 | println(foo() in foo()) + | ~~ + 22 | println(foo() !in foo()) + 23 | println(foo() <- foo()) vlib/v/checker/tests/invalid_multi_return_operations_err.vv:22:9: error: invalid number of operand for `!in`. Only one allowed on each side. 20 | println(foo() || foo()) 21 | println(foo() in foo()) @@ -124,6 +187,13 @@ vlib/v/checker/tests/invalid_multi_return_operations_err.vv:22:9: error: invalid | ~~~~~~~~~~~~~~~ 23 | println(foo() <- foo()) 24 | +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:22:15: error: `!in` can only be used with arrays and maps + 20 | println(foo() || foo()) + 21 | println(foo() in foo()) + 22 | println(foo() !in foo()) + | ~~~ + 23 | println(foo() <- foo()) + 24 | vlib/v/checker/tests/invalid_multi_return_operations_err.vv:23:9: error: invalid number of operand for `<-`. Only one allowed on each side. 21 | println(foo() in foo()) 22 | println(foo() !in foo()) @@ -131,6 +201,20 @@ vlib/v/checker/tests/invalid_multi_return_operations_err.vv:23:9: error: invalid | ~~~~~~~~~~~~~~ 24 | 25 | for _ in foo() .. foo() { +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:23:9: error: cannot push on non-channel `(int, int)` + 21 | println(foo() in foo()) + 22 | println(foo() !in foo()) + 23 | println(foo() <- foo()) + | ~~~~~ + 24 | + 25 | for _ in foo() .. foo() { +vlib/v/checker/tests/invalid_multi_return_operations_err.vv:23:1: error: `println` can not print void expressions + 21 | println(foo() in foo()) + 22 | println(foo() !in foo()) + 23 | println(foo() <- foo()) + | ~~~~~~~~~~~~~~~~~~~~~~~ + 24 | + 25 | for _ in foo() .. foo() { vlib/v/checker/tests/invalid_multi_return_operations_err.vv:25:10: error: multi-returns cannot be used in ranges. A range is from a single value to a single higher value. 23 | println(foo() <- foo()) 24 | diff --git a/vlib/v/checker/tests/invalid_none_operations_err.out b/vlib/v/checker/tests/invalid_none_operations_err.out index c45bd9b738..0279f9338c 100644 --- a/vlib/v/checker/tests/invalid_none_operations_err.out +++ b/vlib/v/checker/tests/invalid_none_operations_err.out @@ -44,6 +44,20 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:7:9: error: invalid operator | ~~~~~~~~~~~~ 8 | println(none >> none) 9 | println(none == none) +vlib/v/checker/tests/invalid_none_operations_err.vv:7:9: error: invalid operation: shift on type `none` + 5 | println(none % none) + 6 | println(none ^ none) + 7 | println(none << none) + | ~~~~ + 8 | println(none >> none) + 9 | println(none == none) +vlib/v/checker/tests/invalid_none_operations_err.vv:7:1: error: `println` can not print void expressions + 5 | println(none % none) + 6 | println(none ^ none) + 7 | println(none << none) + | ~~~~~~~~~~~~~~~~~~~~~ + 8 | println(none >> none) + 9 | println(none == none) vlib/v/checker/tests/invalid_none_operations_err.vv:8:9: error: invalid operator `>>` to `none` and `none` 6 | println(none ^ none) 7 | println(none << none) @@ -51,6 +65,20 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:8:9: error: invalid operator | ~~~~~~~~~~~~ 9 | println(none == none) 10 | println(none != none) +vlib/v/checker/tests/invalid_none_operations_err.vv:8:9: error: invalid operation: shift on type `none` + 6 | println(none ^ none) + 7 | println(none << none) + 8 | println(none >> none) + | ~~~~ + 9 | println(none == none) + 10 | println(none != none) +vlib/v/checker/tests/invalid_none_operations_err.vv:8:1: error: `println` can not print void expressions + 6 | println(none ^ none) + 7 | println(none << none) + 8 | println(none >> none) + | ~~~~~~~~~~~~~~~~~~~~~ + 9 | println(none == none) + 10 | println(none != none) vlib/v/checker/tests/invalid_none_operations_err.vv:9:9: error: invalid operator `==` to `none` and `none` 7 | println(none << none) 8 | println(none >> none) @@ -100,6 +128,20 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:15:9: error: invalid operato | ~~~~~~~~~~~~ 16 | println(none || none) 17 | println(none is none) +vlib/v/checker/tests/invalid_none_operations_err.vv:15:9: error: left operand for `&&` is not a boolean + 13 | println(none >= none) + 14 | println(none <= none) + 15 | println(none && none) + | ~~~~ + 16 | println(none || none) + 17 | println(none is none) +vlib/v/checker/tests/invalid_none_operations_err.vv:15:17: error: right operand for `&&` is not a boolean + 13 | println(none >= none) + 14 | println(none <= none) + 15 | println(none && none) + | ~~~~ + 16 | println(none || none) + 17 | println(none is none) vlib/v/checker/tests/invalid_none_operations_err.vv:16:9: error: invalid operator `||` to `none` and `none` 14 | println(none <= none) 15 | println(none && none) @@ -107,6 +149,20 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:16:9: error: invalid operato | ~~~~~~~~~~~~ 17 | println(none is none) 18 | println(none !is none) +vlib/v/checker/tests/invalid_none_operations_err.vv:16:9: error: left operand for `||` is not a boolean + 14 | println(none <= none) + 15 | println(none && none) + 16 | println(none || none) + | ~~~~ + 17 | println(none is none) + 18 | println(none !is none) +vlib/v/checker/tests/invalid_none_operations_err.vv:16:17: error: right operand for `||` is not a boolean + 14 | println(none <= none) + 15 | println(none && none) + 16 | println(none || none) + | ~~~~ + 17 | println(none is none) + 18 | println(none !is none) vlib/v/checker/tests/invalid_none_operations_err.vv:17:9: error: invalid operator `is` to `none` and `none` 15 | println(none && none) 16 | println(none || none) @@ -114,6 +170,13 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:17:9: error: invalid operato | ~~~~~~~~~~~~ 18 | println(none !is none) 19 | println(none in none) +vlib/v/checker/tests/invalid_none_operations_err.vv:17:14: error: `is` can only be used with interfaces and sum types + 15 | println(none && none) + 16 | println(none || none) + 17 | println(none is none) + | ~~ + 18 | println(none !is none) + 19 | println(none in none) vlib/v/checker/tests/invalid_none_operations_err.vv:18:9: error: invalid operator `!is` to `none` and `none` 16 | println(none || none) 17 | println(none is none) @@ -121,6 +184,13 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:18:9: error: invalid operato | ~~~~~~~~~~~~~ 19 | println(none in none) 20 | println(none !in none) +vlib/v/checker/tests/invalid_none_operations_err.vv:18:14: error: `!is` can only be used with interfaces and sum types + 16 | println(none || none) + 17 | println(none is none) + 18 | println(none !is none) + | ~~~ + 19 | println(none in none) + 20 | println(none !in none) vlib/v/checker/tests/invalid_none_operations_err.vv:19:9: error: invalid operator `in` to `none` and `none` 17 | println(none is none) 18 | println(none !is none) @@ -128,6 +198,13 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:19:9: error: invalid operato | ~~~~~~~~~~~~ 20 | println(none !in none) 21 | println(none <- none) +vlib/v/checker/tests/invalid_none_operations_err.vv:19:14: error: `in` can only be used with arrays and maps + 17 | println(none is none) + 18 | println(none !is none) + 19 | println(none in none) + | ~~ + 20 | println(none !in none) + 21 | println(none <- none) vlib/v/checker/tests/invalid_none_operations_err.vv:20:9: error: invalid operator `!in` to `none` and `none` 18 | println(none !is none) 19 | println(none in none) @@ -135,6 +212,13 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:20:9: error: invalid operato | ~~~~~~~~~~~~~ 21 | println(none <- none) 22 | +vlib/v/checker/tests/invalid_none_operations_err.vv:20:14: error: `!in` can only be used with arrays and maps + 18 | println(none !is none) + 19 | println(none in none) + 20 | println(none !in none) + | ~~~ + 21 | println(none <- none) + 22 | vlib/v/checker/tests/invalid_none_operations_err.vv:21:9: error: invalid operator `<-` to `none` and `none` 19 | println(none in none) 20 | println(none !in none) @@ -142,6 +226,20 @@ vlib/v/checker/tests/invalid_none_operations_err.vv:21:9: error: invalid operato | ~~~~~~~~~~~~ 22 | 23 | for _ in none .. none { +vlib/v/checker/tests/invalid_none_operations_err.vv:21:9: error: cannot push on non-channel `none` + 19 | println(none in none) + 20 | println(none !in none) + 21 | println(none <- none) + | ~~~~ + 22 | + 23 | for _ in none .. none { +vlib/v/checker/tests/invalid_none_operations_err.vv:21:1: error: `println` can not print void expressions + 19 | println(none in none) + 20 | println(none !in none) + 21 | println(none <- none) + | ~~~~~~~~~~~~~~~~~~~~~ + 22 | + 23 | for _ in none .. none { vlib/v/checker/tests/invalid_none_operations_err.vv:23:10: error: range type can not be none 21 | println(none <- none) 22 | diff --git a/vlib/v/checker/tests/invalid_property.out b/vlib/v/checker/tests/invalid_property.out index e7839a42b9..127e9ef4d4 100644 --- a/vlib/v/checker/tests/invalid_property.out +++ b/vlib/v/checker/tests/invalid_property.out @@ -4,6 +4,12 @@ vlib/v/checker/tests/invalid_property.vv:2:7: error: `string` has no property `l | ~~~~~~ 3 | _ = [1,2].foo 4 | +vlib/v/checker/tests/invalid_property.vv:2:3: error: assignment mismatch: 1 variable(s) 0 value(s) + 1 | s :='' + 2 | _ = s.length + | ^ + 3 | _ = [1,2].foo + 4 | vlib/v/checker/tests/invalid_property.vv:3:11: error: `[]int` has no property `foo` 1 | s :='' 2 | _ = s.length @@ -11,8 +17,20 @@ vlib/v/checker/tests/invalid_property.vv:3:11: error: `[]int` has no property `f | ~~~ 4 | 5 | mut fa := [3,4]! +vlib/v/checker/tests/invalid_property.vv:3:3: error: assignment mismatch: 1 variable(s) 0 value(s) + 1 | s :='' + 2 | _ = s.length + 3 | _ = [1,2].foo + | ^ + 4 | + 5 | mut fa := [3,4]! vlib/v/checker/tests/invalid_property.vv:6:8: error: `[2]int` has no property `bar` 4 | 5 | mut fa := [3,4]! 6 | _ = fa.bar | ~~~ +vlib/v/checker/tests/invalid_property.vv:6:3: error: assignment mismatch: 1 variable(s) 0 value(s) + 4 | + 5 | mut fa := [3,4]! + 6 | _ = fa.bar + | ^ diff --git a/vlib/v/checker/tests/invalid_variable_err.out b/vlib/v/checker/tests/invalid_variable_err.out index 42aa07c6ef..20bdfd2e9b 100644 --- a/vlib/v/checker/tests/invalid_variable_err.out +++ b/vlib/v/checker/tests/invalid_variable_err.out @@ -17,3 +17,10 @@ vlib/v/checker/tests/invalid_variable_err.vv:3:5: error: invalid variable `a` | ^ 4 | } 5 | } +vlib/v/checker/tests/invalid_variable_err.vv:3:5: error: non-bool type `void` used as if condition + 1 | fn main() { + 2 | a, b := c + 3 | if a { + | ^ + 4 | } + 5 | } diff --git a/vlib/v/checker/tests/is_type_invalid.out b/vlib/v/checker/tests/is_type_invalid.out index b410205631..1925738b1c 100644 --- a/vlib/v/checker/tests/is_type_invalid.out +++ b/vlib/v/checker/tests/is_type_invalid.out @@ -12,3 +12,10 @@ vlib/v/checker/tests/is_type_invalid.vv:18:10: error: `Cat` doesn't implement me | ~~~ 19 | println('not cool either') 20 | } +vlib/v/checker/tests/is_type_invalid.vv:18:10: error: `Cat` doesn't implement interface `Animal` + 16 | } + 17 | a := Animal(Dog{}) + 18 | if a is Cat { + | ~~~ + 19 | println('not cool either') + 20 | } diff --git a/vlib/v/checker/tests/is_type_not_exist.out b/vlib/v/checker/tests/is_type_not_exist.out index 1c52d7ac11..3803649e8f 100644 --- a/vlib/v/checker/tests/is_type_not_exist.out +++ b/vlib/v/checker/tests/is_type_not_exist.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/is_type_not_exist.vv:8:10: error: is: type `SomethingThatDo | ~~~~~~~~~~~~~~~~~~~~~~ 9 | println('It should fail !') 10 | } +vlib/v/checker/tests/is_type_not_exist.vv:8:10: error: `Integer` has no variant `SomethingThatDontExist` + 6 | + 7 | fn fn_with_sum_type_param(i Integer) { + 8 | if i is SomethingThatDontExist { + | ~~~~~~~~~~~~~~~~~~~~~~ + 9 | println('It should fail !') + 10 | } diff --git a/vlib/v/checker/tests/json_decode.out b/vlib/v/checker/tests/json_decode.out index b0787f1fd9..4d7b569a26 100644 --- a/vlib/v/checker/tests/json_decode.out +++ b/vlib/v/checker/tests/json_decode.out @@ -12,6 +12,13 @@ vlib/v/checker/tests/json_decode.vv:12:7: error: json.decode expects 2 arguments | ~~~~~~~~~~ 13 | json.decode(string, '""')! // BAD 14 | json.decode(Num, '5')! // BAD +vlib/v/checker/tests/json_decode.vv:12:17: error: unexpected `!`, the function `json.decode` does not return a Result + 10 | json.decode(St, '{a: ""}')! // OK + 11 | json.decode(St2, '{a: ""}')! // BAD + 12 | json.decode(St)! // BAD + | ^ + 13 | json.decode(string, '""')! // BAD + 14 | json.decode(Num, '5')! // BAD vlib/v/checker/tests/json_decode.vv:13:14: error: json.decode: expected sum type, struct, map or array, found string 11 | json.decode(St2, '{a: ""}')! // BAD 12 | json.decode(St)! // BAD diff --git a/vlib/v/checker/tests/json_decode_shared_err.out b/vlib/v/checker/tests/json_decode_shared_err.out index 0295cc9b7c..cafbf9a346 100644 --- a/vlib/v/checker/tests/json_decode_shared_err.out +++ b/vlib/v/checker/tests/json_decode_shared_err.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/json_decode_shared_err.vv:6:16: error: json.encode cannot h | ~~~~~~~~~~~~ 7 | } 8 | } +vlib/v/checker/tests/json_decode_shared_err.vv:6:3: error: `println` can not print void expressions + 4 | shared data := [1, 2, 3] + 5 | rlock data { + 6 | println(json.encode(data)) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~ + 7 | } + 8 | } diff --git a/vlib/v/checker/tests/lambda_expression_in_map.out b/vlib/v/checker/tests/lambda_expression_in_map.out index e2c46e734d..f9d567329d 100644 --- a/vlib/v/checker/tests/lambda_expression_in_map.out +++ b/vlib/v/checker/tests/lambda_expression_in_map.out @@ -5,8 +5,20 @@ vlib/v/checker/tests/lambda_expression_in_map.vv:3:12: error: lambda expressions | ~~ 4 | dump(a.map(|x| 5 * x)) 5 | dump(a.map(|x| x)) +vlib/v/checker/tests/lambda_expression_in_map.vv:3:8: error: dump expression can not be void + 1 | a := [4, 5] + 2 | dump(a.map(it)) + 3 | dump(a.map(|| 5)) + | ~~~~~~~~~ + 4 | dump(a.map(|x| 5 * x)) + 5 | dump(a.map(|x| x)) vlib/v/checker/tests/lambda_expression_in_map.vv:6:12: error: lambda expressions used in the builtin array methods require exactly 1 parameter 4 | dump(a.map(|x| 5 * x)) 5 | dump(a.map(|x| x)) 6 | dump(a.map(|x, y| x)) | ^ +vlib/v/checker/tests/lambda_expression_in_map.vv:6:8: error: dump expression can not be void + 4 | dump(a.map(|x| 5 * x)) + 5 | dump(a.map(|x| x)) + 6 | dump(a.map(|x, y| x)) + | ~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/like_operator_with_non_string_type_error.out b/vlib/v/checker/tests/like_operator_with_non_string_type_error.out index 7561d1b6d5..bbcd4725c4 100644 --- a/vlib/v/checker/tests/like_operator_with_non_string_type_error.out +++ b/vlib/v/checker/tests/like_operator_with_non_string_type_error.out @@ -12,3 +12,17 @@ vlib/v/checker/tests/like_operator_with_non_string_type_error.vv:16:26: error: t | ~~ 17 | }!) 18 | } +vlib/v/checker/tests/like_operator_with_non_string_type_error.vv:16:34: error: the right operand of the `like` operator must be a string type + 14 | + 15 | println(sql db { + 16 | select from User where 10 like true + | ~~~~ + 17 | }!) + 18 | } +vlib/v/checker/tests/like_operator_with_non_string_type_error.vv:16:26: error: V ORM: left side of the `like` expression must be one of the `User`'s fields + 14 | + 15 | println(sql db { + 16 | select from User where 10 like true + | ~~ + 17 | }!) + 18 | } diff --git a/vlib/v/checker/tests/lock_already_locked.out b/vlib/v/checker/tests/lock_already_locked.out index ae6152c3dd..68a3fbb654 100644 --- a/vlib/v/checker/tests/lock_already_locked.out +++ b/vlib/v/checker/tests/lock_already_locked.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/lock_already_locked.vv:11:3: error: nested `lock`/`rlock` n | ~~~~~ 12 | a.x++ 13 | } +vlib/v/checker/tests/lock_already_locked.vv:11:9: error: `a` is already locked + 9 | } + 10 | lock a { + 11 | rlock a { + | ^ + 12 | a.x++ + 13 | } vlib/v/checker/tests/lock_already_locked.vv:12:4: error: a has an `rlock` but needs a `lock` 10 | lock a { 11 | rlock a { @@ -12,6 +19,13 @@ vlib/v/checker/tests/lock_already_locked.vv:12:4: error: a has an `rlock` but ne | ^ 13 | } 14 | } +vlib/v/checker/tests/lock_already_locked.vv:12:4: error: `a` is `shared` and needs explicit lock for `v.ast.SelectorExpr` + 10 | lock a { + 11 | rlock a { + 12 | a.x++ + | ^ + 13 | } + 14 | } vlib/v/checker/tests/lock_already_locked.vv:15:10: error: `a` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print 13 | } 14 | } diff --git a/vlib/v/checker/tests/lock_already_rlocked.out b/vlib/v/checker/tests/lock_already_rlocked.out index b7e3fdabc5..a489ad28f5 100644 --- a/vlib/v/checker/tests/lock_already_rlocked.out +++ b/vlib/v/checker/tests/lock_already_rlocked.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/lock_already_rlocked.vv:11:3: error: nested `lock`/`rlock` | ~~~~ 12 | a.x++ 13 | } +vlib/v/checker/tests/lock_already_rlocked.vv:11:8: error: `a` is already read-locked + 9 | } + 10 | rlock a { + 11 | lock a { + | ^ + 12 | a.x++ + 13 | } vlib/v/checker/tests/lock_already_rlocked.vv:15:10: error: `a` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print 13 | } 14 | } diff --git a/vlib/v/checker/tests/map_delete.out b/vlib/v/checker/tests/map_delete.out index ecfbca0e21..7706f321ff 100644 --- a/vlib/v/checker/tests/map_delete.out +++ b/vlib/v/checker/tests/map_delete.out @@ -12,6 +12,13 @@ vlib/v/checker/tests/map_delete.vv:6:4: error: expected 1 argument, but got 2 | ~~~~~~~~~~~~ 7 | m2 := { 8 | '1': 1 +vlib/v/checker/tests/map_delete.vv:6:11: error: cannot use `int literal` as `string` in argument 1 to `Map.delete` + 4 | } + 5 | m.delete(1) + 6 | m.delete(1, 2) + | ^ + 7 | m2 := { + 8 | '1': 1 vlib/v/checker/tests/map_delete.vv:10:2: error: `m2` is immutable, declare it with `mut` to make it mutable 8 | '1': 1 9 | } diff --git a/vlib/v/checker/tests/map_ops.out b/vlib/v/checker/tests/map_ops.out index d30508bfd7..6738739df1 100644 --- a/vlib/v/checker/tests/map_ops.out +++ b/vlib/v/checker/tests/map_ops.out @@ -12,9 +12,28 @@ vlib/v/checker/tests/map_ops.vv:4:3: error: invalid key: expected `int`, not `st | ~~~~~~ 5 | m[&m] += 4 6 | } +vlib/v/checker/tests/map_ops.vv:4:12: error: cannot assign to `m['hi']`: expected `string`, not `int literal` + 2 | mut m := map[int]string + 3 | _ = m[`!`] + 4 | m['hi'] = 8 + | ^ + 5 | m[&m] += 4 + 6 | } vlib/v/checker/tests/map_ops.vv:5:3: error: invalid key: expected `int`, not `&map[int]string` 3 | _ = m[`!`] 4 | m['hi'] = 8 5 | m[&m] += 4 | ~~~~ 6 | } +vlib/v/checker/tests/map_ops.vv:5:11: error: invalid right operand: string += int literal + 3 | _ = m[`!`] + 4 | m['hi'] = 8 + 5 | m[&m] += 4 + | ^ + 6 | } +vlib/v/checker/tests/map_ops.vv:5:11: error: cannot assign to `m[&m]`: expected `string`, not `int literal` + 3 | _ = m[`!`] + 4 | m['hi'] = 8 + 5 | m[&m] += 4 + | ^ + 6 | } diff --git a/vlib/v/checker/tests/match_expr_else.out b/vlib/v/checker/tests/match_expr_else.out index cf708333d1..e6bb91dea2 100644 --- a/vlib/v/checker/tests/match_expr_else.out +++ b/vlib/v/checker/tests/match_expr_else.out @@ -19,3 +19,10 @@ vlib/v/checker/tests/match_expr_else.vv:34:3: error: `else` must be the last bra | ~~~~ 35 | 'else' 36 | } +vlib/v/checker/tests/match_expr_else.vv:34:3: error: match expression is exhaustive, `else` is unnecessary + 32 | 'string' + 33 | } + 34 | else { + | ~~~~ + 35 | 'else' + 36 | } diff --git a/vlib/v/checker/tests/match_sumtype_multiple_types.out b/vlib/v/checker/tests/match_sumtype_multiple_types.out index 9f2201f41f..a156c11e17 100644 --- a/vlib/v/checker/tests/match_sumtype_multiple_types.out +++ b/vlib/v/checker/tests/match_sumtype_multiple_types.out @@ -5,10 +5,24 @@ vlib/v/checker/tests/match_sumtype_multiple_types.vv:26:13: error: type `Charlie | ~~~~ 27 | assert l.letter() == 'a' 28 | } +vlib/v/checker/tests/match_sumtype_multiple_types.vv:26:11: error: assert can be used only with `bool` expressions, but found `void` instead + 24 | match l { + 25 | Alfa, Charlie { + 26 | assert l.char == `a` + | ~~~~~~~~~~~~~ + 27 | assert l.letter() == 'a' + 28 | } vlib/v/checker/tests/match_sumtype_multiple_types.vv:27:13: error: unknown method: `Charlie.letter` 25 | Alfa, Charlie { 26 | assert l.char == `a` 27 | assert l.letter() == 'a' | ~~~~~~~~ 28 | } - 29 | Bravo { \ No newline at end of file + 29 | Bravo { +vlib/v/checker/tests/match_sumtype_multiple_types.vv:27:11: error: assert can be used only with `bool` expressions, but found `void` instead + 25 | Alfa, Charlie { + 26 | assert l.char == `a` + 27 | assert l.letter() == 'a' + | ~~~~~~~~~~~~~~~~~ + 28 | } + 29 | Bravo { diff --git a/vlib/v/checker/tests/method_array_slice.out b/vlib/v/checker/tests/method_array_slice.out index dde905525b..67b59f9709 100644 --- a/vlib/v/checker/tests/method_array_slice.out +++ b/vlib/v/checker/tests/method_array_slice.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/method_array_slice.vv:5:12: error: .slice() is a private me | ~~~~~~~~ 6 | println(a[1..]) 7 | } +vlib/v/checker/tests/method_array_slice.vv:5:2: error: `println` can not print void expressions + 3 | fn main() { + 4 | a := os.args.clone() + 5 | println(a.slice(1)) + | ~~~~~~~~~~~~~~~~~~~ + 6 | println(a[1..]) + 7 | } diff --git a/vlib/v/checker/tests/method_call_with_empty_struct_init.out b/vlib/v/checker/tests/method_call_with_empty_struct_init.out index c8d98ed7db..ea23669c83 100644 --- a/vlib/v/checker/tests/method_call_with_empty_struct_init.out +++ b/vlib/v/checker/tests/method_call_with_empty_struct_init.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/method_call_with_empty_struct_init.vv:10:11: error: `{}` ca 10 | s.abc(0, {}) | ~~ 11 | } +vlib/v/checker/tests/method_call_with_empty_struct_init.vv:10:11: error: `map{ }` (no value) used as value in argument 2 to `Abc.abc` + 8 | fn main() { + 9 | s := Abc{} + 10 | s.abc(0, {}) + | ~~ + 11 | } diff --git a/vlib/v/checker/tests/method_op_err.out b/vlib/v/checker/tests/method_op_err.out index 547ceea909..c1ee67430d 100644 --- a/vlib/v/checker/tests/method_op_err.out +++ b/vlib/v/checker/tests/method_op_err.out @@ -47,6 +47,13 @@ vlib/v/checker/tests/method_op_err.vv:34:13: error: mismatched types `User` and | ~~~~~~~~~~~~~~~~~~~~~~ 35 | mut u := User{3, 4} 36 | _ = u +vlib/v/checker/tests/method_op_err.vv:34:13: error: infix expr: cannot use `Foo` (right expression) as `User` + 32 | println(User{3, 4} - Foo{3, 3}) + 33 | println(User{3, 2} < User{2, 4}) + 34 | println(User{3, 4} < Foo{3, 4}) + | ~~~~~~~~~~~~~~~~~~~~~~ + 35 | mut u := User{3, 4} + 36 | _ = u vlib/v/checker/tests/method_op_err.vv:37:10: error: cannot assign to `u`: expected `User`, not `int literal` 35 | mut u := User{3, 4} 36 | _ = u @@ -61,6 +68,13 @@ vlib/v/checker/tests/method_op_err.vv:38:5: error: operator %= not defined on le | ^ 39 | u += User{2, 3} 40 | } +vlib/v/checker/tests/method_op_err.vv:38:7: error: undefined operation `User` % `User` + 36 | _ = u + 37 | u += 12 + 38 | u %= User{1, 3} + | ~~ + 39 | u += User{2, 3} + 40 | } vlib/v/checker/tests/method_op_err.vv:39:7: error: operator `+` must return `User` to be used as an assignment operator 37 | u += 12 38 | u %= User{1, 3} diff --git a/vlib/v/checker/tests/minus_op_wrong_type_err.out b/vlib/v/checker/tests/minus_op_wrong_type_err.out index 802d7aef8b..0caf3bc001 100644 --- a/vlib/v/checker/tests/minus_op_wrong_type_err.out +++ b/vlib/v/checker/tests/minus_op_wrong_type_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/minus_op_wrong_type_err.vv:10:10: error: mismatched types ` | ~~~~~~~~~~ 11 | println(10 - Aaa{}) 12 | println([1, 2, 3] - 10) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:10:10: error: infix expr: cannot use `int literal` (right expression) as `Aaa` + 8 | + 9 | fn main() { + 10 | println(Aaa{} - 10) + | ~~~~~~~~~~ + 11 | println(10 - Aaa{}) + 12 | println([1, 2, 3] - 10) vlib/v/checker/tests/minus_op_wrong_type_err.vv:11:10: error: mismatched types `int literal` and `Aaa` 9 | fn main() { 10 | println(Aaa{} - 10) @@ -12,6 +19,13 @@ vlib/v/checker/tests/minus_op_wrong_type_err.vv:11:10: error: mismatched types ` | ~~~~~~~~~~ 12 | println([1, 2, 3] - 10) 13 | println(10 - [1, 2, 3]) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:11:10: error: infix expr: cannot use `Aaa` (right expression) as `int literal` + 9 | fn main() { + 10 | println(Aaa{} - 10) + 11 | println(10 - Aaa{}) + | ~~~~~~~~~~ + 12 | println([1, 2, 3] - 10) + 13 | println(10 - [1, 2, 3]) vlib/v/checker/tests/minus_op_wrong_type_err.vv:12:10: error: mismatched types `[]int` and `int literal` 10 | println(Aaa{} - 10) 11 | println(10 - Aaa{}) @@ -19,6 +33,13 @@ vlib/v/checker/tests/minus_op_wrong_type_err.vv:12:10: error: mismatched types ` | ~~~~~~~~~~~~~~ 13 | println(10 - [1, 2, 3]) 14 | a := map[string]int{} +vlib/v/checker/tests/minus_op_wrong_type_err.vv:12:10: error: infix expr: cannot use `int literal` (right expression) as `[]int` + 10 | println(Aaa{} - 10) + 11 | println(10 - Aaa{}) + 12 | println([1, 2, 3] - 10) + | ~~~~~~~~~~~~~~ + 13 | println(10 - [1, 2, 3]) + 14 | a := map[string]int{} vlib/v/checker/tests/minus_op_wrong_type_err.vv:13:10: error: mismatched types `int literal` and `[]int` 11 | println(10 - Aaa{}) 12 | println([1, 2, 3] - 10) @@ -26,6 +47,13 @@ vlib/v/checker/tests/minus_op_wrong_type_err.vv:13:10: error: mismatched types ` | ~~~~~~~~~~~~~~ 14 | a := map[string]int{} 15 | println(a - 10) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:13:10: error: infix expr: cannot use `[]int` (right expression) as `int literal` + 11 | println(10 - Aaa{}) + 12 | println([1, 2, 3] - 10) + 13 | println(10 - [1, 2, 3]) + | ~~~~~~~~~~~~~~ + 14 | a := map[string]int{} + 15 | println(a - 10) vlib/v/checker/tests/minus_op_wrong_type_err.vv:15:10: error: mismatched types `map[string]int` and `int literal` 13 | println(10 - [1, 2, 3]) 14 | a := map[string]int{} @@ -33,6 +61,13 @@ vlib/v/checker/tests/minus_op_wrong_type_err.vv:15:10: error: mismatched types ` | ~~~~~~ 16 | println(10 - a) 17 | println(-Aaa{}) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:15:10: error: infix expr: cannot use `int literal` (right expression) as `map[string]int` + 13 | println(10 - [1, 2, 3]) + 14 | a := map[string]int{} + 15 | println(a - 10) + | ~~~~~~ + 16 | println(10 - a) + 17 | println(-Aaa{}) vlib/v/checker/tests/minus_op_wrong_type_err.vv:16:10: error: mismatched types `int literal` and `map[string]int` 14 | a := map[string]int{} 15 | println(a - 10) @@ -40,6 +75,13 @@ vlib/v/checker/tests/minus_op_wrong_type_err.vv:16:10: error: mismatched types ` | ~~~~~~ 17 | println(-Aaa{}) 18 | println(-a) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:16:10: error: infix expr: cannot use `map[string]int` (right expression) as `int literal` + 14 | a := map[string]int{} + 15 | println(a - 10) + 16 | println(10 - a) + | ~~~~~~ + 17 | println(-Aaa{}) + 18 | println(-a) vlib/v/checker/tests/minus_op_wrong_type_err.vv:17:10: error: operator `-` can only be used with numeric types, but the value after `-` is of type `Aaa` instead 15 | println(a - 10) 16 | println(10 - a) diff --git a/vlib/v/checker/tests/mismatched_ptr_op_ptr.out b/vlib/v/checker/tests/mismatched_ptr_op_ptr.out index a1a1d8af34..32324405fc 100644 --- a/vlib/v/checker/tests/mismatched_ptr_op_ptr.out +++ b/vlib/v/checker/tests/mismatched_ptr_op_ptr.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/mismatched_ptr_op_ptr.vv:5:17: error: mismatched types `&st | ~~~ 6 | println(b+b) 7 | } +vlib/v/checker/tests/mismatched_ptr_op_ptr.vv:5:9: error: `println` can not print void expressions + 3 | unsafe { + 4 | b := &a + 5 | println(b+*b) + | ~~~~~~~~~~~~~ + 6 | println(b+b) + 7 | } vlib/v/checker/tests/mismatched_ptr_op_ptr.vv:6:17: error: invalid operator `+` to `&string` and `&string` 4 | b := &a 5 | println(b+*b) diff --git a/vlib/v/checker/tests/misspelled_mod_const_should_have_suggestion.out b/vlib/v/checker/tests/misspelled_mod_const_should_have_suggestion.out index ccd510a636..875ffb57cf 100644 --- a/vlib/v/checker/tests/misspelled_mod_const_should_have_suggestion.out +++ b/vlib/v/checker/tests/misspelled_mod_const_should_have_suggestion.out @@ -4,3 +4,8 @@ Did you mean `time.second`? 2 | 3 | time.sleep(1 * time.secondz) | ~~~~~~~ +vlib/v/checker/tests/misspelled_mod_const_should_have_suggestion.vv:3:12: error: `1 * time.secondz` (no value) used as value in argument 1 to `time.sleep` + 1 | import time + 2 | + 3 | time.sleep(1 * time.secondz) + | ~~~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/misspelled_mod_fn_name_should_have_suggestion.out b/vlib/v/checker/tests/misspelled_mod_fn_name_should_have_suggestion.out index 8ff5208c5d..35f39d5966 100644 --- a/vlib/v/checker/tests/misspelled_mod_fn_name_should_have_suggestion.out +++ b/vlib/v/checker/tests/misspelled_mod_fn_name_should_have_suggestion.out @@ -4,3 +4,8 @@ Did you mean `os.read_file`? 2 | 3 | dump(os.read_fil('abc')) | ~~~~~~~~~~~~~~~ +vlib/v/checker/tests/misspelled_mod_fn_name_should_have_suggestion.vv:3:9: error: dump expression can not be void + 1 | import os + 2 | + 3 | dump(os.read_fil('abc')) + | ~~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/mod_op_wrong_type_err.out b/vlib/v/checker/tests/mod_op_wrong_type_err.out index 6ae53be6bd..1fb7974390 100644 --- a/vlib/v/checker/tests/mod_op_wrong_type_err.out +++ b/vlib/v/checker/tests/mod_op_wrong_type_err.out @@ -19,6 +19,13 @@ vlib/v/checker/tests/mod_op_wrong_type_err.vv:5:10: error: mismatched types `[]i | ~~~~~~~~~~~ 6 | println(1 % [1,2,3]) 7 | a := Aaa{} +vlib/v/checker/tests/mod_op_wrong_type_err.vv:5:10: error: infix expr: cannot use `int literal` (right expression) as `[]int` + 3 | println(0.5 % 1) + 4 | println(1 % 0.5) + 5 | println([1,2,3] % 1) + | ~~~~~~~~~~~ + 6 | println(1 % [1,2,3]) + 7 | a := Aaa{} vlib/v/checker/tests/mod_op_wrong_type_err.vv:6:10: error: mismatched types `int literal` and `[]int` 4 | println(1 % 0.5) 5 | println([1,2,3] % 1) @@ -26,6 +33,13 @@ vlib/v/checker/tests/mod_op_wrong_type_err.vv:6:10: error: mismatched types `int | ~~~~~~~~~~~ 7 | a := Aaa{} 8 | println(a % 1) +vlib/v/checker/tests/mod_op_wrong_type_err.vv:6:10: error: infix expr: cannot use `[]int` (right expression) as `int literal` + 4 | println(1 % 0.5) + 5 | println([1,2,3] % 1) + 6 | println(1 % [1,2,3]) + | ~~~~~~~~~~~ + 7 | a := Aaa{} + 8 | println(a % 1) vlib/v/checker/tests/mod_op_wrong_type_err.vv:8:10: error: mismatched types `Aaa` and `int literal` 6 | println(1 % [1,2,3]) 7 | a := Aaa{} @@ -33,6 +47,13 @@ vlib/v/checker/tests/mod_op_wrong_type_err.vv:8:10: error: mismatched types `Aaa | ~~~~~ 9 | println(1 % a) 10 | b := map[string]int +vlib/v/checker/tests/mod_op_wrong_type_err.vv:8:10: error: infix expr: cannot use `int literal` (right expression) as `Aaa` + 6 | println(1 % [1,2,3]) + 7 | a := Aaa{} + 8 | println(a % 1) + | ~~~~~ + 9 | println(1 % a) + 10 | b := map[string]int vlib/v/checker/tests/mod_op_wrong_type_err.vv:9:10: error: mismatched types `int literal` and `Aaa` 7 | a := Aaa{} 8 | println(a % 1) @@ -40,6 +61,13 @@ vlib/v/checker/tests/mod_op_wrong_type_err.vv:9:10: error: mismatched types `int | ~~~~~ 10 | b := map[string]int 11 | println(b % 1) +vlib/v/checker/tests/mod_op_wrong_type_err.vv:9:10: error: infix expr: cannot use `Aaa` (right expression) as `int literal` + 7 | a := Aaa{} + 8 | println(a % 1) + 9 | println(1 % a) + | ~~~~~ + 10 | b := map[string]int + 11 | println(b % 1) vlib/v/checker/tests/mod_op_wrong_type_err.vv:11:10: error: mismatched types `map[string]int` and `int literal` 9 | println(1 % a) 10 | b := map[string]int @@ -47,10 +75,22 @@ vlib/v/checker/tests/mod_op_wrong_type_err.vv:11:10: error: mismatched types `ma | ~~~~~ 12 | println(1 % b) 13 | } +vlib/v/checker/tests/mod_op_wrong_type_err.vv:11:10: error: infix expr: cannot use `int literal` (right expression) as `map[string]int` + 9 | println(1 % a) + 10 | b := map[string]int + 11 | println(b % 1) + | ~~~~~ + 12 | println(1 % b) + 13 | } vlib/v/checker/tests/mod_op_wrong_type_err.vv:12:10: error: mismatched types `int literal` and `map[string]int` 10 | b := map[string]int 11 | println(b % 1) 12 | println(1 % b) | ~~~~~ 13 | } - +vlib/v/checker/tests/mod_op_wrong_type_err.vv:12:10: error: infix expr: cannot use `map[string]int` (right expression) as `int literal` + 10 | b := map[string]int + 11 | println(b % 1) + 12 | println(1 % b) + | ~~~~~ + 13 | } diff --git a/vlib/v/checker/tests/modules/deprecated_module.out b/vlib/v/checker/tests/modules/deprecated_module.out index 1ccfee7c8f..87056136f2 100644 --- a/vlib/v/checker/tests/modules/deprecated_module.out +++ b/vlib/v/checker/tests/modules/deprecated_module.out @@ -11,3 +11,9 @@ vlib/v/checker/tests/modules/deprecated_module/main.v:16:11: error: undefined id 16 | dump(ttt.non_existing) | ~~~~~~~~~~~~ 17 | } +vlib/v/checker/tests/modules/deprecated_module/main.v:16:11: error: dump expression can not be void + 14 | dump(ttt.f()) + 15 | dump(yyy.f()) + 16 | dump(ttt.non_existing) + | ~~~~~~~~~~~~ + 17 | } diff --git a/vlib/v/checker/tests/mul_op_wrong_type_err.out b/vlib/v/checker/tests/mul_op_wrong_type_err.out index 6bd5ff9ab7..10ca288dd8 100644 --- a/vlib/v/checker/tests/mul_op_wrong_type_err.out +++ b/vlib/v/checker/tests/mul_op_wrong_type_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/mul_op_wrong_type_err.vv:5:13: error: mismatched types `Aaa | ~~~~~~~~~~ 6 | println(10 * Aaa{}) 7 | println([1,2,3] * 10) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:5:13: error: infix expr: cannot use `int literal` (right expression) as `Aaa` + 3 | struct Aaa{} + 4 | fn main() { + 5 | println(Aaa{} * 10) + | ~~~~~~~~~~ + 6 | println(10 * Aaa{}) + 7 | println([1,2,3] * 10) vlib/v/checker/tests/mul_op_wrong_type_err.vv:6:13: error: mismatched types `int literal` and `Aaa` 4 | fn main() { 5 | println(Aaa{} * 10) @@ -12,6 +19,13 @@ vlib/v/checker/tests/mul_op_wrong_type_err.vv:6:13: error: mismatched types `int | ~~~~~~~~~~ 7 | println([1,2,3] * 10) 8 | println(10 * [1,2,3]) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:6:13: error: infix expr: cannot use `Aaa` (right expression) as `int literal` + 4 | fn main() { + 5 | println(Aaa{} * 10) + 6 | println(10 * Aaa{}) + | ~~~~~~~~~~ + 7 | println([1,2,3] * 10) + 8 | println(10 * [1,2,3]) vlib/v/checker/tests/mul_op_wrong_type_err.vv:7:13: error: mismatched types `[]int` and `int literal` 5 | println(Aaa{} * 10) 6 | println(10 * Aaa{}) @@ -19,6 +33,13 @@ vlib/v/checker/tests/mul_op_wrong_type_err.vv:7:13: error: mismatched types `[]i | ~~~~~~~~~~~~ 8 | println(10 * [1,2,3]) 9 | a := map[string]int +vlib/v/checker/tests/mul_op_wrong_type_err.vv:7:13: error: infix expr: cannot use `int literal` (right expression) as `[]int` + 5 | println(Aaa{} * 10) + 6 | println(10 * Aaa{}) + 7 | println([1,2,3] * 10) + | ~~~~~~~~~~~~ + 8 | println(10 * [1,2,3]) + 9 | a := map[string]int vlib/v/checker/tests/mul_op_wrong_type_err.vv:8:13: error: mismatched types `int literal` and `[]int` 6 | println(10 * Aaa{}) 7 | println([1,2,3] * 10) @@ -26,6 +47,13 @@ vlib/v/checker/tests/mul_op_wrong_type_err.vv:8:13: error: mismatched types `int | ~~~~~~~~~~~~ 9 | a := map[string]int 10 | println(a * 10) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:8:13: error: infix expr: cannot use `[]int` (right expression) as `int literal` + 6 | println(10 * Aaa{}) + 7 | println([1,2,3] * 10) + 8 | println(10 * [1,2,3]) + | ~~~~~~~~~~~~ + 9 | a := map[string]int + 10 | println(a * 10) vlib/v/checker/tests/mul_op_wrong_type_err.vv:10:13: error: mismatched types `map[string]int` and `int literal` 8 | println(10 * [1,2,3]) 9 | a := map[string]int @@ -33,6 +61,13 @@ vlib/v/checker/tests/mul_op_wrong_type_err.vv:10:13: error: mismatched types `ma | ~~~~~~ 11 | println(10 * a) 12 | c1 := cmplx.complex(1,-2) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:10:13: error: infix expr: cannot use `int literal` (right expression) as `map[string]int` + 8 | println(10 * [1,2,3]) + 9 | a := map[string]int + 10 | println(a * 10) + | ~~~~~~ + 11 | println(10 * a) + 12 | c1 := cmplx.complex(1,-2) vlib/v/checker/tests/mul_op_wrong_type_err.vv:11:13: error: mismatched types `int literal` and `map[string]int` 9 | a := map[string]int 10 | println(a * 10) @@ -40,6 +75,13 @@ vlib/v/checker/tests/mul_op_wrong_type_err.vv:11:13: error: mismatched types `in | ~~~~~~ 12 | c1 := cmplx.complex(1,-2) 13 | c2 := c1 * 2.0 +vlib/v/checker/tests/mul_op_wrong_type_err.vv:11:13: error: infix expr: cannot use `map[string]int` (right expression) as `int literal` + 9 | a := map[string]int + 10 | println(a * 10) + 11 | println(10 * a) + | ~~~~~~ + 12 | c1 := cmplx.complex(1,-2) + 13 | c2 := c1 * 2.0 vlib/v/checker/tests/mul_op_wrong_type_err.vv:13:8: error: infix expr: cannot use `float literal` (right expression) as `math.complex.Complex` 11 | println(10 * a) 12 | c1 := cmplx.complex(1,-2) @@ -54,4 +96,3 @@ vlib/v/checker/tests/mul_op_wrong_type_err.vv:15:8: error: infix expr: cannot us | ~~~~~~~~ 16 | println(c3) 17 | } - diff --git a/vlib/v/checker/tests/mut_arg.out b/vlib/v/checker/tests/mut_arg.out index 253d73a9e8..5b7d277e37 100644 --- a/vlib/v/checker/tests/mut_arg.out +++ b/vlib/v/checker/tests/mut_arg.out @@ -19,6 +19,13 @@ vlib/v/checker/tests/mut_arg.vv:6:3: error: function `f` parameter `par` is `mut | ~~~~~ 7 | mut a := [1,2] 8 | f(a) +vlib/v/checker/tests/mut_arg.vv:6:3: error: cannot use `[]int` as `&[]int` in argument 1 to `f` + 4 | } + 5 | + 6 | f([3,4]) + | ~~~~~ + 7 | mut a := [1,2] + 8 | f(a) vlib/v/checker/tests/mut_arg.vv:8:3: error: function `f` parameter `par` is `mut`, so use `mut a` instead 6 | f([3,4]) 7 | mut a := [1,2] @@ -26,12 +33,31 @@ vlib/v/checker/tests/mut_arg.vv:8:3: error: function `f` parameter `par` is `mut | ^ 9 | 10 | g(mut [3,4]) +vlib/v/checker/tests/mut_arg.vv:8:3: error: cannot use `[]int` as `&[]int` in argument 1 to `f` + 6 | f([3,4]) + 7 | mut a := [1,2] + 8 | f(a) + | ^ + 9 | + 10 | g(mut [3,4]) vlib/v/checker/tests/mut_arg.vv:10:7: error: array literal can not be modified 8 | f(a) 9 | 10 | g(mut [3,4]) | ~~~~~ 11 | g(mut a) +vlib/v/checker/tests/mut_arg.vv:10:7: error: cannot pass expression as `mut` + 8 | f(a) + 9 | + 10 | g(mut [3,4]) + | ~~~~~ + 11 | g(mut a) +vlib/v/checker/tests/mut_arg.vv:10:7: error: `g` parameter `par` is not `mut`, `mut` is not needed` + 8 | f(a) + 9 | + 10 | g(mut [3,4]) + | ~~~~~ + 11 | g(mut a) vlib/v/checker/tests/mut_arg.vv:11:7: error: `g` parameter `par` is not `mut`, `mut` is not needed` 9 | 10 | g(mut [3,4]) diff --git a/vlib/v/checker/tests/nil.out b/vlib/v/checker/tests/nil.out index cbe3f705da..58a774c3b7 100644 --- a/vlib/v/checker/tests/nil.out +++ b/vlib/v/checker/tests/nil.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/nil.vv:2:11: error: `nil` is only allowed in `unsafe` code | ~~~ 3 | println(value) 4 | } +vlib/v/checker/tests/nil.vv:2:11: error: use of untyped nil in assignment (use `unsafe` | false) + 1 | fn main() { + 2 | value := nil + | ~~~ + 3 | println(value) + 4 | } diff --git a/vlib/v/checker/tests/option_propagate_nested.out b/vlib/v/checker/tests/option_propagate_nested.out index 2b3b006fdd..a690a20bef 100644 --- a/vlib/v/checker/tests/option_propagate_nested.out +++ b/vlib/v/checker/tests/option_propagate_nested.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/option_propagate_nested.vv:10:18: error: to propagate the Option call, `xx_prop` must return an Option - 8 | + 8 | 9 | fn xx_prop() string { 10 | s := ret(raise()?) | ^ @@ -7,13 +7,27 @@ vlib/v/checker/tests/option_propagate_nested.vv:10:18: error: to propagate the O 12 | } Details: vlib/v/checker/tests/option_propagate_nested.vv:9:14: details: prepend ? before the declaration of the return type of `xx_prop` 7 | } - 8 | + 8 | + 9 | fn xx_prop() string { + | ~~~~~~ + 10 | s := ret(raise()?) + 11 | return s +vlib/v/checker/tests/option_propagate_nested.vv:10:18: error: to propagate the call, `xx_prop` must return an Option type + 8 | + 9 | fn xx_prop() string { + 10 | s := ret(raise()?) + | ^ + 11 | return s + 12 | } +Details: vlib/v/checker/tests/option_propagate_nested.vv:9:14: details: prepend ? before the declaration of the return type of `xx_prop` + 7 | } + 8 | 9 | fn xx_prop() string { | ~~~~~~ 10 | s := ret(raise()?) 11 | return s vlib/v/checker/tests/option_propagate_nested.vv:28:21: error: to propagate the Result call, `aa_propagate` must return a Result - 26 | + 26 | 27 | fn (mut s St) aa_propagate() { 28 | f := retf(s.raise()!) | ^ @@ -21,7 +35,21 @@ vlib/v/checker/tests/option_propagate_nested.vv:28:21: error: to propagate the R 30 | println(f) Details: vlib/v/checker/tests/option_propagate_nested.vv:27:30: details: prepend ! before the declaration of the return type of `aa_propagate` 25 | } - 26 | + 26 | + 27 | fn (mut s St) aa_propagate() { + | ^ + 28 | f := retf(s.raise()!) + 29 | s.z = 7.5 +vlib/v/checker/tests/option_propagate_nested.vv:28:21: error: to propagate the call, `aa_propagate` must return a Result type + 26 | + 27 | fn (mut s St) aa_propagate() { + 28 | f := retf(s.raise()!) + | ^ + 29 | s.z = 7.5 + 30 | println(f) +Details: vlib/v/checker/tests/option_propagate_nested.vv:27:30: details: prepend ! before the declaration of the return type of `aa_propagate` + 25 | } + 26 | 27 | fn (mut s St) aa_propagate() { | ^ 28 | f := retf(s.raise()!) diff --git a/vlib/v/checker/tests/option_ptr_err.out b/vlib/v/checker/tests/option_ptr_err.out index 5096b8d5e1..2c71fc0164 100644 --- a/vlib/v/checker/tests/option_ptr_err.out +++ b/vlib/v/checker/tests/option_ptr_err.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/option_ptr_err.vv:3:10: error: type `?int` is an Option, it 3 | assert *var == 0 | ~~~ 4 | } +vlib/v/checker/tests/option_ptr_err.vv:3:9: error: unwrapped Option cannot be used in an infix expression + 1 | fn main() { + 2 | mut var := unsafe { ?&int(none) } + 3 | assert *var == 0 + | ^ + 4 | } diff --git a/vlib/v/checker/tests/option_type_call_err.out b/vlib/v/checker/tests/option_type_call_err.out index f789eeeec1..a785626bed 100644 --- a/vlib/v/checker/tests/option_type_call_err.out +++ b/vlib/v/checker/tests/option_type_call_err.out @@ -4,3 +4,15 @@ vlib/v/checker/tests/option_type_call_err.vv:4:5: error: os.ls() returns a Resul 4 | os.ls('.').filter(it.ends_with('.v')) or { return } | ~~~~~~~ 5 | } +vlib/v/checker/tests/option_type_call_err.vv:4:5: error: Result type cannot be called directly + 2 | + 3 | fn main() { + 4 | os.ls('.').filter(it.ends_with('.v')) or { return } + | ~~~~~~~ + 5 | } +vlib/v/checker/tests/option_type_call_err.vv:4:40: error: unexpected `or` block, the function `filter` does not return an Option or a Result + 2 | + 3 | fn main() { + 4 | os.ls('.').filter(it.ends_with('.v')) or { return } + | ~~~~~~~~~~~~~ + 5 | } diff --git a/vlib/v/checker/tests/option_var_unwrap_err.out b/vlib/v/checker/tests/option_var_unwrap_err.out index 58d1887898..b2f416cbdf 100644 --- a/vlib/v/checker/tests/option_var_unwrap_err.out +++ b/vlib/v/checker/tests/option_var_unwrap_err.out @@ -12,3 +12,10 @@ Details: vlib/v/checker/tests/option_var_unwrap_err.vv:4:21: details: prepend ? | ~~~~~~ 5 | return a? 6 | } +vlib/v/checker/tests/option_var_unwrap_err.vv:5:2: error: should not unwrap option var on return, it could be none + 3 | + 4 | fn abc_2(a ?string) string { + 5 | return a? + | ~~~~~~~~ + 6 | } + 7 | diff --git a/vlib/v/checker/tests/orm_db_expr_option_error.out b/vlib/v/checker/tests/orm_db_expr_option_error.out index c04311c847..ea35c7edd1 100644 --- a/vlib/v/checker/tests/orm_db_expr_option_error.out +++ b/vlib/v/checker/tests/orm_db_expr_option_error.out @@ -12,6 +12,48 @@ vlib/v/checker/tests/orm_db_expr_option_error.vv:22:11: error: `Account` doesn't | ~~~~~~~ 23 | select from Account 24 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:22:11: error: `Account` doesn't implement method `insert` of interface `orm.Connection` + 20 | account := Account{} + 21 | + 22 | _ := sql account { + | ~~~~~~~ + 23 | select from Account + 24 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:22:11: error: `Account` doesn't implement method `update` of interface `orm.Connection` + 20 | account := Account{} + 21 | + 22 | _ := sql account { + | ~~~~~~~ + 23 | select from Account + 24 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:22:11: error: `Account` doesn't implement method `delete` of interface `orm.Connection` + 20 | account := Account{} + 21 | + 22 | _ := sql account { + | ~~~~~~~ + 23 | select from Account + 24 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:22:11: error: `Account` doesn't implement method `create` of interface `orm.Connection` + 20 | account := Account{} + 21 | + 22 | _ := sql account { + | ~~~~~~~ + 23 | select from Account + 24 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:22:11: error: `Account` doesn't implement method `drop` of interface `orm.Connection` + 20 | account := Account{} + 21 | + 22 | _ := sql account { + | ~~~~~~~ + 23 | select from Account + 24 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:22:11: error: `Account` doesn't implement method `last_id` of interface `orm.Connection` + 20 | account := Account{} + 21 | + 22 | _ := sql account { + | ~~~~~~~ + 23 | select from Account + 24 | }! vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't implement method `select` of interface `orm.Connection` 24 | }! 25 | @@ -19,6 +61,48 @@ vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't | ~~~~~~~ 27 | insert account into Account 28 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't implement method `insert` of interface `orm.Connection` + 24 | }! + 25 | + 26 | sql account { + | ~~~~~~~ + 27 | insert account into Account + 28 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't implement method `update` of interface `orm.Connection` + 24 | }! + 25 | + 26 | sql account { + | ~~~~~~~ + 27 | insert account into Account + 28 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't implement method `delete` of interface `orm.Connection` + 24 | }! + 25 | + 26 | sql account { + | ~~~~~~~ + 27 | insert account into Account + 28 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't implement method `create` of interface `orm.Connection` + 24 | }! + 25 | + 26 | sql account { + | ~~~~~~~ + 27 | insert account into Account + 28 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't implement method `drop` of interface `orm.Connection` + 24 | }! + 25 | + 26 | sql account { + | ~~~~~~~ + 27 | insert account into Account + 28 | }! +vlib/v/checker/tests/orm_db_expr_option_error.vv:26:6: error: `Account` doesn't implement method `last_id` of interface `orm.Connection` + 24 | }! + 25 | + 26 | sql account { + | ~~~~~~~ + 27 | insert account into Account + 28 | }! vlib/v/checker/tests/orm_db_expr_option_error.vv:30:6: error: expected `sqlite.DB`, not `?sqlite.DB` 28 | }! 29 | diff --git a/vlib/v/checker/tests/os_prefix.out b/vlib/v/checker/tests/os_prefix.out index 4b87a6fff7..ac35b74c8c 100644 --- a/vlib/v/checker/tests/os_prefix.out +++ b/vlib/v/checker/tests/os_prefix.out @@ -1,7 +1,7 @@ vlib/v/checker/tests/os_prefix.vv:1:8: warning: module 'os' is imported but never used 1 | import os | ~~ - 2 | + 2 | 3 | fn main() { vlib/v/checker/tests/os_prefix.vv:5:12: error: unknown function: execute 3 | fn main() { @@ -10,6 +10,13 @@ vlib/v/checker/tests/os_prefix.vv:5:12: error: unknown function: execute | ~~~~~~~~~~~~ 6 | println(result) 7 | } +vlib/v/checker/tests/os_prefix.vv:5:9: error: assignment mismatch: 1 variable(s) but `execute()` returns 0 value(s) + 3 | fn main() { + 4 | cmd := "ls" + 5 | result := execute(cmd) + | ~~ + 6 | println(result) + 7 | } vlib/v/checker/tests/os_prefix.vv:6:2: error: `println` can not print void expressions 4 | cmd := "ls" 5 | result := execute(cmd) diff --git a/vlib/v/checker/tests/par_expr_assign_void_right_type_err.out b/vlib/v/checker/tests/par_expr_assign_void_right_type_err.out index 4945afaf0f..dfb7e4e85b 100644 --- a/vlib/v/checker/tests/par_expr_assign_void_right_type_err.out +++ b/vlib/v/checker/tests/par_expr_assign_void_right_type_err.out @@ -1,12 +1,6 @@ vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:6: warning: redundant parentheses are used 1 | _ := ((((print(10))))) | ~~~~~~~~~~~~~~~~~ -vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:7: warning: redundant parentheses are used - 1 | _ := ((((print(10))))) - | ~~~~~~~~~~~~~~~ -vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:8: warning: redundant parentheses are used - 1 | _ := ((((print(10))))) - | ~~~~~~~~~~~~~ vlib/v/checker/tests/par_expr_assign_void_right_type_err.vv:1:3: error: assignment mismatch: expected 1 value(s) but `print()` returns 0 value(s) 1 | _ := ((((print(10))))) | ~~ diff --git a/vlib/v/checker/tests/pointer_ops.out b/vlib/v/checker/tests/pointer_ops.out index fa2d2abb02..6aa773f106 100644 --- a/vlib/v/checker/tests/pointer_ops.out +++ b/vlib/v/checker/tests/pointer_ops.out @@ -54,6 +54,13 @@ vlib/v/checker/tests/pointer_ops.vv:15:3: error: invalid operator `%` to `&Foo` | ~~~~~~~ 16 | } 17 | } +vlib/v/checker/tests/pointer_ops.vv:15:3: error: mismatched types `&Foo` and `int literal` + 13 | _ = p[3] + 14 | mut foo := &Foo{} + 15 | foo % 3 + | ~~~~~~~ + 16 | } + 17 | } vlib/v/checker/tests/pointer_ops.vv:22:7: error: `+` cannot be used with `voidptr` 20 | unsafe { 21 | mut p := nil @@ -110,3 +117,10 @@ vlib/v/checker/tests/pointer_ops.vv:30:3: error: invalid operator `%` to `&Foo` | ~~~~~~~ 31 | } 32 | } +vlib/v/checker/tests/pointer_ops.vv:30:3: error: mismatched types `&Foo` and `int literal` + 28 | _ = p[3] + 29 | mut foo := &Foo{} + 30 | foo % 3 + | ~~~~~~~ + 31 | } + 32 | } diff --git a/vlib/v/checker/tests/prefix_expr_decl_assign_err.out b/vlib/v/checker/tests/prefix_expr_decl_assign_err.out index 70986913a0..fdbb4cf9e1 100644 --- a/vlib/v/checker/tests/prefix_expr_decl_assign_err.out +++ b/vlib/v/checker/tests/prefix_expr_decl_assign_err.out @@ -4,6 +4,12 @@ vlib/v/checker/tests/prefix_expr_decl_assign_err.vv:2:5: error: cannot use a ref | ^ 3 | (*d) := 14 4 | } +vlib/v/checker/tests/prefix_expr_decl_assign_err.vv:2:5: error: non-name on the left side of `:=` + 1 | fn main() { + 2 | &a := 12 + | ^ + 3 | (*d) := 14 + 4 | } vlib/v/checker/tests/prefix_expr_decl_assign_err.vv:3:5: error: non-name `(*d)` on left side of `:=` 1 | fn main() { 2 | &a := 12 diff --git a/vlib/v/checker/tests/res_use_outside_defer.out b/vlib/v/checker/tests/res_use_outside_defer.out index 54122a0db0..42f09b0f46 100644 --- a/vlib/v/checker/tests/res_use_outside_defer.out +++ b/vlib/v/checker/tests/res_use_outside_defer.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/res_use_outside_defer.vv:2:10: error: `res` can only be use | ~~~~~~ 3 | return 'test' 4 | } +vlib/v/checker/tests/res_use_outside_defer.vv:2:2: error: `println` can not print void expressions + 1 | fn test() string { + 2 | println($res()) + | ~~~~~~~~~~~~~~~ + 3 | return 'test' + 4 | } diff --git a/vlib/v/checker/tests/result_type_call_err.out b/vlib/v/checker/tests/result_type_call_err.out index c8b79f74ec..e4c945d5d6 100644 --- a/vlib/v/checker/tests/result_type_call_err.out +++ b/vlib/v/checker/tests/result_type_call_err.out @@ -4,3 +4,15 @@ vlib/v/checker/tests/result_type_call_err.vv:12:2: error: new_foo() returns a Re 12 | new_foo().foo() | ~~~~~~~~~ 13 | } +vlib/v/checker/tests/result_type_call_err.vv:12:2: error: Result type cannot be called directly + 10 | + 11 | fn main() { + 12 | new_foo().foo() + | ~~~~~~~~~ + 13 | } +vlib/v/checker/tests/result_type_call_err.vv:12:12: error: foo() returns a Result, so it should have either an `or {}` block, or `!` at the end + 10 | + 11 | fn main() { + 12 | new_foo().foo() + | ~~~~~ + 13 | } diff --git a/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out b/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out index 60866d5051..b2fd31a4a0 100644 --- a/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out +++ b/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out @@ -3,3 +3,8 @@ vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv:2:10: error: invalid opera 2 | println(0.5 >> 1) | ~~~ 3 | } +vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv:2:2: error: `println` can not print void expressions + 1 | fn main() { + 2 | println(0.5 >> 1) + | ~~~~~~~~~~~~~~~~~ + 3 | } diff --git a/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out b/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out index 7a0c5d9b86..d733fecd21 100644 --- a/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out +++ b/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out @@ -3,3 +3,8 @@ vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv:2:15: error: cannot shift 2 | println(1 >> 0.5) | ~~~ 3 | } +vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv:2:2: error: `println` can not print void expressions + 1 | fn main() { + 2 | println(1 >> 0.5) + | ~~~~~~~~~~~~~~~~~ + 3 | } diff --git a/vlib/v/checker/tests/shared_bad_args.out b/vlib/v/checker/tests/shared_bad_args.out index e41873c5dc..6694a7a196 100644 --- a/vlib/v/checker/tests/shared_bad_args.out +++ b/vlib/v/checker/tests/shared_bad_args.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/shared_bad_args.vv:43:8: error: `r` is `shared` and must be | ^ 44 | println(u) 45 | } +vlib/v/checker/tests/shared_bad_args.vv:43:8: error: `r` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut right-hand side of assignment + 41 | shared r := Qr{ a: 7 } + 42 | lock s { + 43 | u := r.s_val(s) + | ^ + 44 | println(u) + 45 | } vlib/v/checker/tests/shared_bad_args.vv:47:16: error: `s` is `shared` and must be `rlock`ed or `lock`ed to be passed as non-mut argument 45 | } 46 | lock r { @@ -33,6 +40,13 @@ vlib/v/checker/tests/shared_bad_args.vv:61:3: error: r must be added to the `loc | ^ 62 | } 63 | lock r { +vlib/v/checker/tests/shared_bad_args.vv:61:3: error: r is `shared` and must be `lock`ed to be passed as `mut` + 59 | shared r := Qr{ a: 7 } + 60 | lock s { + 61 | r.s_mut(mut s) + | ^ + 62 | } + 63 | lock r { vlib/v/checker/tests/shared_bad_args.vv:64:15: error: s must be added to the `lock` list above 62 | } 63 | lock r { @@ -40,6 +54,13 @@ vlib/v/checker/tests/shared_bad_args.vv:64:15: error: s must be added to the `lo | ^ 65 | } 66 | m_mut(mut m) +vlib/v/checker/tests/shared_bad_args.vv:64:15: error: s is `shared` and must be `lock`ed to be passed as `mut` + 62 | } + 63 | lock r { + 64 | r.s_mut(mut s) + | ^ + 65 | } + 66 | m_mut(mut m) vlib/v/checker/tests/shared_bad_args.vv:66:12: error: m is `shared` and must be `lock`ed to be passed as `mut` 64 | r.s_mut(mut s) 65 | } diff --git a/vlib/v/checker/tests/shared_lock.out b/vlib/v/checker/tests/shared_lock.out index 62d71304a4..2758fd3959 100644 --- a/vlib/v/checker/tests/shared_lock.out +++ b/vlib/v/checker/tests/shared_lock.out @@ -12,6 +12,13 @@ vlib/v/checker/tests/shared_lock.vv:20:7: error: method with `shared` arguments | ^ 21 | f(0, x) 22 | } +vlib/v/checker/tests/shared_lock.vv:20:7: error: method `m` parameter `x` is `shared`, so use `shared x` instead + 18 | lock x { + 19 | x.r(x) + 20 | x.m(x) + | ^ + 21 | f(0, x) + 22 | } vlib/v/checker/tests/shared_lock.vv:21:8: error: function with `shared` arguments cannot be called inside `lock`/`rlock` block 19 | x.r(x) 20 | x.m(x) @@ -19,3 +26,10 @@ vlib/v/checker/tests/shared_lock.vv:21:8: error: function with `shared` argument | ^ 22 | } 23 | } +vlib/v/checker/tests/shared_lock.vv:21:8: error: function `f` parameter `x` is `shared`, so use `shared x` instead + 19 | x.r(x) + 20 | x.m(x) + 21 | f(0, x) + | ^ + 22 | } + 23 | } diff --git a/vlib/v/checker/tests/shift_op_wrong_left_type_err.out b/vlib/v/checker/tests/shift_op_wrong_left_type_err.out index 1bdeb5e2e2..8cfca1439b 100644 --- a/vlib/v/checker/tests/shift_op_wrong_left_type_err.out +++ b/vlib/v/checker/tests/shift_op_wrong_left_type_err.out @@ -3,3 +3,8 @@ vlib/v/checker/tests/shift_op_wrong_left_type_err.vv:2:10: error: invalid operat 2 | println(0.5 << 1) | ~~~ 3 | } +vlib/v/checker/tests/shift_op_wrong_left_type_err.vv:2:2: error: `println` can not print void expressions + 1 | fn main() { + 2 | println(0.5 << 1) + | ~~~~~~~~~~~~~~~~~ + 3 | } diff --git a/vlib/v/checker/tests/shift_op_wrong_right_type_err.out b/vlib/v/checker/tests/shift_op_wrong_right_type_err.out index 87d0a44972..7381ce6ee8 100644 --- a/vlib/v/checker/tests/shift_op_wrong_right_type_err.out +++ b/vlib/v/checker/tests/shift_op_wrong_right_type_err.out @@ -3,3 +3,8 @@ vlib/v/checker/tests/shift_op_wrong_right_type_err.vv:2:15: error: cannot shift 2 | println(1 << 0.5) | ~~~ 3 | } +vlib/v/checker/tests/shift_op_wrong_right_type_err.vv:2:2: error: `println` can not print void expressions + 1 | fn main() { + 2 | println(1 << 0.5) + | ~~~~~~~~~~~~~~~~~ + 3 | } diff --git a/vlib/v/checker/tests/shift_ops_expressions.out b/vlib/v/checker/tests/shift_ops_expressions.out index 7823c17689..cad80513eb 100644 --- a/vlib/v/checker/tests/shift_ops_expressions.out +++ b/vlib/v/checker/tests/shift_ops_expressions.out @@ -19,27 +19,6 @@ vlib/v/checker/tests/shift_ops_expressions.vv:8:17: notice: shifting a value fro | ^ 9 | println(c) 10 | a << 1 -vlib/v/checker/tests/shift_ops_expressions.vv:8:17: notice: shifting a value from a signed type `int` can change the sign - 6 | a << 2 - 7 | } - 8 | c := if true { a << 111 } else { a << 333 } - | ^ - 9 | println(c) - 10 | a << 1 -vlib/v/checker/tests/shift_ops_expressions.vv:8:35: notice: shifting a value from a signed type `int` can change the sign - 6 | a << 2 - 7 | } - 8 | c := if true { a << 111 } else { a << 333 } - | ^ - 9 | println(c) - 10 | a << 1 -vlib/v/checker/tests/shift_ops_expressions.vv:8:35: notice: shifting a value from a signed type `int` can change the sign - 6 | a << 2 - 7 | } - 8 | c := if true { a << 111 } else { a << 333 } - | ^ - 9 | println(c) - 10 | a << 1 vlib/v/checker/tests/shift_ops_expressions.vv:10:2: notice: shifting a value from a signed type `int` can change the sign 8 | c := if true { a << 111 } else { a << 333 } 9 | println(c) @@ -117,6 +96,13 @@ vlib/v/checker/tests/shift_ops_expressions.vv:37:8: error: shift count for type | ~~~~ 38 | println('---') 39 | 555 +vlib/v/checker/tests/shift_ops_expressions.vv:37:3: error: unused expression + 35 | } else { + 36 | println('---') + 37 | a << 9999 + | ~~~~~~~~~ + 38 | println('---') + 39 | 555 vlib/v/checker/tests/shift_ops_expressions.vv:50:23: error: shift count for type `int` too large (maximum: 31 bits) 48 | rr >> 2 49 | } diff --git a/vlib/v/checker/tests/static_method_not_found_err.out b/vlib/v/checker/tests/static_method_not_found_err.out index 0cd3b82822..2c74bf69c1 100644 --- a/vlib/v/checker/tests/static_method_not_found_err.out +++ b/vlib/v/checker/tests/static_method_not_found_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/static_method_not_found_err.vv:10:9: error: unknown functio | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 | println(val) 12 | } +vlib/v/checker/tests/static_method_not_found_err.vv:10:6: error: assignment mismatch: 1 variable(s) but `TestStruct.static_method()` returns 0 value(s) + 8 | + 9 | fn main() { + 10 | val := TestStruct.static_method() + | ~~ + 11 | println(val) + 12 | } vlib/v/checker/tests/static_method_not_found_err.vv:11:2: error: `println` can not print void expressions 9 | fn main() { 10 | val := TestStruct.static_method() diff --git a/vlib/v/checker/tests/str_method_return_string.out b/vlib/v/checker/tests/str_method_return_string.out index 43bb36a3b8..9e9b35de9e 100644 --- a/vlib/v/checker/tests/str_method_return_string.out +++ b/vlib/v/checker/tests/str_method_return_string.out @@ -1,4 +1,11 @@ -vlib/v/checker/tests/str_method_return_string.vv:5:1: error: .str() methods should return `string` +vlib/v/checker/tests/str_method_return_string.vv:5:1: error: .str() methods should return `string` + 3 | } + 4 | + 5 | fn (z Zzz) str(x int) int { + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + 6 | return z.x + 7 | } +vlib/v/checker/tests/str_method_return_string.vv:5:1: error: .str() methods should have 0 arguments 3 | } 4 | 5 | fn (z Zzz) str(x int) int { diff --git a/vlib/v/checker/tests/string_interpolation_wrong_fmt.out b/vlib/v/checker/tests/string_interpolation_wrong_fmt.out index 4c9d7aea2f..b989948046 100644 --- a/vlib/v/checker/tests/string_interpolation_wrong_fmt.out +++ b/vlib/v/checker/tests/string_interpolation_wrong_fmt.out @@ -1,60 +1,67 @@ -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:3:16: error: precision specification only valid for float types +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:3:16: error: precision specification only valid for float types 1 | fn interpolate_str() string { 2 | a := 'hallo' 3 | x := '>${a:8.3s}<' | ^ 4 | y := '${a:G}' 5 | z := '${a:d}' -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:4:12: error: illegal format specifier `G` for type `string` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:4:12: error: illegal format specifier `G` for type `string` 2 | a := 'hallo' 3 | x := '>${a:8.3s}<' 4 | y := '${a:G}' | ^ 5 | z := '${a:d}' 6 | return x + y + z -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:5:12: error: illegal format specifier `d` for type `string` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:5:12: error: illegal format specifier `d` for type `string` 3 | x := '>${a:8.3s}<' 4 | y := '${a:G}' 5 | z := '${a:d}' | ^ 6 | return x + y + z 7 | } -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:11:15: error: illegal format specifier `s` for type `f64` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:11:15: error: illegal format specifier `s` for type `f64` 9 | fn interpolate_f64() string { 10 | b := 1367.57 11 | x := '>${b:20s}<' | ^ 12 | y := '${b:d}' 13 | return x + y -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:12:12: error: illegal format specifier `d` for type `f64` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:12:12: error: illegal format specifier `d` for type `f64` 10 | b := 1367.57 11 | x := '>${b:20s}<' 12 | y := '${b:d}' | ^ 13 | return x + y 14 | } -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:19:14: error: illegal format specifier `d` for type `u32` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:19:14: error: illegal format specifier `d` for type `u32` 17 | u := u32(15) 18 | s := -12 19 | x := '${u:13d}' | ^ 20 | y := '${s:04u}' 21 | z := '${s:f}' -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:20:14: error: illegal format specifier `u` for type `int` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:20:14: error: illegal format specifier `u` for type `int` 18 | s := -12 19 | x := '${u:13d}' 20 | y := '${s:04u}' | ^ 21 | z := '${s:f}' 22 | q := '${u:v}' -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:21:12: error: illegal format specifier `f` for type `int` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:21:12: error: illegal format specifier `f` for type `int` 19 | x := '${u:13d}' 20 | y := '${s:04u}' 21 | z := '${s:f}' | ^ 22 | q := '${u:v}' 23 | return x + y + z + q -vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:22:12: error: unknown format specifier `v` +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:22:12: error: unknown format specifier `v` + 20 | y := '${s:04u}' + 21 | z := '${s:f}' + 22 | q := '${u:v}' + | ^ + 23 | return x + y + z + q + 24 | } +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:22:12: error: illegal format specifier `v` for type `u32` 20 | y := '${s:04u}' 21 | z := '${s:f}' 22 | q := '${u:v}' diff --git a/vlib/v/checker/tests/struct_embed_required_field_err.out b/vlib/v/checker/tests/struct_embed_required_field_err.out index 94ce63bcf9..5786f7e0aa 100644 --- a/vlib/v/checker/tests/struct_embed_required_field_err.out +++ b/vlib/v/checker/tests/struct_embed_required_field_err.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/struct_embed_required_field_err.vv:12:7: error: field `Bar. | ~~~~~ 13 | foo: 1 14 | } +vlib/v/checker/tests/struct_embed_required_field_err.vv:12:7: error: field `Foo.bar` must be initialized + 10 | + 11 | fn main() { + 12 | b := Bar { + | ~~~~~ + 13 | foo: 1 + 14 | } diff --git a/vlib/v/checker/tests/struct_field_assign_internal_types_nil_err.out b/vlib/v/checker/tests/struct_field_assign_internal_types_nil_err.out index 2503d7d3eb..37b765408b 100644 --- a/vlib/v/checker/tests/struct_field_assign_internal_types_nil_err.out +++ b/vlib/v/checker/tests/struct_field_assign_internal_types_nil_err.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/struct_field_assign_internal_types_nil_err.vv:15:8: error: cannot assign `nil` to struct field `name` with type `string` - 13 | + 13 | 14 | a := &Foo{ 15 | name: unsafe { nil } | ~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/struct_field_reference_type_err.out b/vlib/v/checker/tests/struct_field_reference_type_err.out index 534556e123..72fe73b1f9 100644 --- a/vlib/v/checker/tests/struct_field_reference_type_err.out +++ b/vlib/v/checker/tests/struct_field_reference_type_err.out @@ -1,12 +1,19 @@ vlib/v/checker/tests/struct_field_reference_type_err.vv:12:16: error: reference field `Animal.duck.age` must be initialized (part of struct `Duck`) - 10 | + 10 | + 11 | fn main() { + 12 | mut animal := Animal{ + | ~~~~~~~ + 13 | ageee: 20 + 14 | } +vlib/v/checker/tests/struct_field_reference_type_err.vv:12:16: error: reference field `Duck.age` must be initialized + 10 | 11 | fn main() { 12 | mut animal := Animal{ | ~~~~~~~ 13 | ageee: 20 14 | } vlib/v/checker/tests/struct_field_reference_type_err.vv:17:3: error: reference field must be initialized with reference - 15 | + 15 | 16 | animal.duck = Duck{ 17 | age: animal.ageee | ~~~~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/struct_field_type_err.out b/vlib/v/checker/tests/struct_field_type_err.out index 53da8cf6ff..ee47700fc7 100644 --- a/vlib/v/checker/tests/struct_field_type_err.out +++ b/vlib/v/checker/tests/struct_field_type_err.out @@ -35,9 +35,16 @@ vlib/v/checker/tests/struct_field_type_err.vv:16:3: error: cannot assign to fiel | ~~~~~~~~~~ 17 | } 18 | -vlib/v/checker/tests/struct_field_type_err.vv:19:11: error: cannot assign to `data.n`: expected `int`, not `bool` +vlib/v/checker/tests/struct_field_type_err.vv:16:3: error: reference field must be initialized with reference + 14 | f1: fn (v ...voidptr) {} + 15 | f2: fn (v voidptr) {} + 16 | data: true + | ~~~~~~~~~~ 17 | } 18 | +vlib/v/checker/tests/struct_field_type_err.vv:19:11: error: cannot assign to `data.n`: expected `int`, not `bool` + 17 | } + 18 | 19 | data.n = true | ~~~~ 20 | } diff --git a/vlib/v/checker/tests/struct_field_with_default_err.out b/vlib/v/checker/tests/struct_field_with_default_err.out index e3aae1b330..3d9c819012 100644 --- a/vlib/v/checker/tests/struct_field_with_default_err.out +++ b/vlib/v/checker/tests/struct_field_with_default_err.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/struct_field_with_default_err.vv:2:22: error: unknown struc | ~~~ 3 | } 4 | +vlib/v/checker/tests/struct_field_with_default_err.vv:2:22: error: incompatible initializer for field `arbitrary_field`: expected `T`, not `void` + 1 | struct Dummy[T] { + 2 | arbitrary_field T = T{} + | ~~~ + 3 | } + 4 | diff --git a/vlib/v/checker/tests/struct_pub_field.out b/vlib/v/checker/tests/struct_pub_field.out index c0c34c7c83..60de44ac3e 100644 --- a/vlib/v/checker/tests/struct_pub_field.out +++ b/vlib/v/checker/tests/struct_pub_field.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/struct_pub_field.vv:9:4: error: field `i` of struct `Foo` i 9 | a.i = 2 | ^ 10 | } +vlib/v/checker/tests/struct_pub_field.vv:9:2: error: `a` is immutable, declare it with `mut` to make it mutable + 7 | i: 1 + 8 | } + 9 | a.i = 2 + | ^ + 10 | } diff --git a/vlib/v/checker/tests/struct_ref_fields_uninitialized_err.out b/vlib/v/checker/tests/struct_ref_fields_uninitialized_err.out index 1636e861f1..0ce3317fd6 100644 --- a/vlib/v/checker/tests/struct_ref_fields_uninitialized_err.out +++ b/vlib/v/checker/tests/struct_ref_fields_uninitialized_err.out @@ -1,5 +1,19 @@ vlib/v/checker/tests/struct_ref_fields_uninitialized_err.vv:25:7: error: reference field `Outer.c1.b` must be initialized (part of struct `ContainsRef`) - 23 | + 23 | + 24 | fn main() { + 25 | _ := Outer{} + | ~~~~~~~ + 26 | _ := Struct{} + 27 | } +vlib/v/checker/tests/struct_ref_fields_uninitialized_err.vv:25:7: error: reference field `ContainsRef.b` must be initialized + 23 | + 24 | fn main() { + 25 | _ := Outer{} + | ~~~~~~~ + 26 | _ := Struct{} + 27 | } +vlib/v/checker/tests/struct_ref_fields_uninitialized_err.vv:25:7: error: reference field `Outer.c2.b` must be initialized (part of struct `ContainsRef`) + 23 | 24 | fn main() { 25 | _ := Outer{} | ~~~~~~~ @@ -11,3 +25,9 @@ vlib/v/checker/tests/struct_ref_fields_uninitialized_err.vv:26:7: error: referen 26 | _ := Struct{} | ~~~~~~~~ 27 | } +vlib/v/checker/tests/struct_ref_fields_uninitialized_err.vv:26:7: error: reference field `EmbedStruct.ref2` must be initialized + 24 | fn main() { + 25 | _ := Outer{} + 26 | _ := Struct{} + | ~~~~~~~~ + 27 | } diff --git a/vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.out b/vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.out index 606535797b..d06ca9b20b 100644 --- a/vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.out +++ b/vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.vv:11:3: error | ~~~~~~~~ 12 | } 13 | } +vlib/v/checker/tests/struct_voidptr_field_no_ptr_struct_value_err.vv:11:3: error: cannot assign to field `a`: expected a pointer `voidptr`, but got `Foo` + 9 | fn main() { + 10 | _ := Foo2{ + 11 | a: Foo{} + | ~~~~~~~~ + 12 | } + 13 | } diff --git a/vlib/v/checker/tests/sum_type_common_fields_alias_error.out b/vlib/v/checker/tests/sum_type_common_fields_alias_error.out index 20c3b008b0..79f268b3f9 100644 --- a/vlib/v/checker/tests/sum_type_common_fields_alias_error.out +++ b/vlib/v/checker/tests/sum_type_common_fields_alias_error.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:35:14: error: field ` | ~~~~ 36 | assert m[1].name == 'def' 37 | assert m[2].name == 'xyz' +vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:35:9: error: assert can be used only with `bool` expressions, but found `void` instead + 33 | } + 34 | println(m) + 35 | assert m[0].name == 'abc' + | ~~~~~~~~~~~~~~~~~~ + 36 | assert m[1].name == 'def' + 37 | assert m[2].name == 'xyz' vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:36:14: error: field `name` does not exist or have the same type in all sumtype variants 34 | println(m) 35 | assert m[0].name == 'abc' @@ -12,9 +19,22 @@ vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:36:14: error: field ` | ~~~~ 37 | assert m[2].name == 'xyz' 38 | } +vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:36:9: error: assert can be used only with `bool` expressions, but found `void` instead + 34 | println(m) + 35 | assert m[0].name == 'abc' + 36 | assert m[1].name == 'def' + | ~~~~~~~~~~~~~~~~~~ + 37 | assert m[2].name == 'xyz' + 38 | } vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:37:14: error: field `name` does not exist or have the same type in all sumtype variants 35 | assert m[0].name == 'abc' 36 | assert m[1].name == 'def' 37 | assert m[2].name == 'xyz' | ~~~~ 38 | } +vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:37:9: error: assert can be used only with `bool` expressions, but found `void` instead + 35 | assert m[0].name == 'abc' + 36 | assert m[1].name == 'def' + 37 | assert m[2].name == 'xyz' + | ~~~~~~~~~~~~~~~~~~ + 38 | } diff --git a/vlib/v/checker/tests/sum_type_common_fields_error.out b/vlib/v/checker/tests/sum_type_common_fields_error.out index 9dce91ab09..ec05ff5b74 100644 --- a/vlib/v/checker/tests/sum_type_common_fields_error.out +++ b/vlib/v/checker/tests/sum_type_common_fields_error.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/sum_type_common_fields_error.vv:53:14: error: field `val` d 53 | assert m[0].val == 123 | ~~~ 54 | } +vlib/v/checker/tests/sum_type_common_fields_error.vv:53:9: error: assert can be used only with `bool` expressions, but found `void` instead + 51 | assert m[2].name == '64bit integer' + 52 | assert m[3].name == 'string' + 53 | assert m[0].val == 123 + | ~~~~~~~~~~~~~~~ + 54 | } diff --git a/vlib/v/checker/tests/sum_type_exists.out b/vlib/v/checker/tests/sum_type_exists.out index 03597f0a98..ab144c58ae 100644 --- a/vlib/v/checker/tests/sum_type_exists.out +++ b/vlib/v/checker/tests/sum_type_exists.out @@ -1,3 +1,6 @@ vlib/v/checker/tests/sum_type_exists.vv:1:22: error: unknown type `Inexistent` 1 | type Miscellaneous = Inexistent | Nope | int - | ~~~~~~~~~~ \ No newline at end of file + | ~~~~~~~~~~ +vlib/v/checker/tests/sum_type_exists.vv:1:35: error: unknown type `Nope` + 1 | type Miscellaneous = Inexistent | Nope | int + | ~~~~ diff --git a/vlib/v/checker/tests/sum_type_infix_err.out b/vlib/v/checker/tests/sum_type_infix_err.out index 6a06f1b90c..4a6662a5bb 100644 --- a/vlib/v/checker/tests/sum_type_infix_err.out +++ b/vlib/v/checker/tests/sum_type_infix_err.out @@ -12,3 +12,10 @@ vlib/v/checker/tests/sum_type_infix_err.vv:6:11: error: cannot use operator `+` | ^ 7 | _ = unsafe{&x + 5} 8 | } +vlib/v/checker/tests/sum_type_infix_err.vv:6:7: error: infix expr: cannot use `Abc` (right expression) as `int literal` + 4 | x := Abc(0) + 5 | _ := x + Abc(5) + 6 | _ := 123 + x + | ~~~~~~~ + 7 | _ = unsafe{&x + 5} + 8 | } diff --git a/vlib/v/checker/tests/sum_type_mutable_cast_err.out b/vlib/v/checker/tests/sum_type_mutable_cast_err.out index a880221f43..89423de77b 100644 --- a/vlib/v/checker/tests/sum_type_mutable_cast_err.out +++ b/vlib/v/checker/tests/sum_type_mutable_cast_err.out @@ -5,6 +5,13 @@ vlib/v/checker/tests/sum_type_mutable_cast_err.vv:15:10: error: cannot use opera | ^ 16 | } 17 | mut f := Foo{Bar{Abc(0)}} +vlib/v/checker/tests/sum_type_mutable_cast_err.vv:15:8: error: infix expr: cannot use `int literal` (right expression) as `Abc` + 13 | mut x := Abc(0) + 14 | if x is int { + 15 | _ := x + 5 + | ~~~~~ + 16 | } + 17 | mut f := Foo{Bar{Abc(0)}} vlib/v/checker/tests/sum_type_mutable_cast_err.vv:19:14: error: cannot use operator `+` with `Abc` 17 | mut f := Foo{Bar{Abc(0)}} 18 | if f.b.a is int { @@ -12,3 +19,10 @@ vlib/v/checker/tests/sum_type_mutable_cast_err.vv:19:14: error: cannot use opera | ^ 20 | } 21 | } +vlib/v/checker/tests/sum_type_mutable_cast_err.vv:19:12: error: infix expr: cannot use `int literal` (right expression) as `Abc` + 17 | mut f := Foo{Bar{Abc(0)}} + 18 | if f.b.a is int { + 19 | _ := f.b.a + 5 + | ~~~~~ + 20 | } + 21 | } diff --git a/vlib/v/checker/tests/test_functions_wrong_signature_test.out b/vlib/v/checker/tests/test_functions_wrong_signature_test.out index b544f0aa09..79704baf0f 100644 --- a/vlib/v/checker/tests/test_functions_wrong_signature_test.out +++ b/vlib/v/checker/tests/test_functions_wrong_signature_test.out @@ -1,12 +1,19 @@ vlib/v/checker/tests/test_functions_wrong_signature_test.vv:9:1: error: test functions should either return nothing at all, or be marked to return `?` or `!` - 7 | + 7 | + 8 | // should be disallowed: + 9 | fn test_returning_int() int { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 10 | } + 11 | +vlib/v/checker/tests/test_functions_wrong_signature_test.vv:9:1: error: missing return at end of function `test_returning_int` + 7 | 8 | // should be disallowed: 9 | fn test_returning_int() int { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 | } 11 | vlib/v/checker/tests/test_functions_wrong_signature_test.vv:19:1: error: test functions should take 0 parameters - 17 | + 17 | 18 | // should be disallowed: 19 | fn test_take_parameters(v int) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out b/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out index 82a7bb7718..4cdeaa5712 100644 --- a/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out +++ b/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out @@ -1,28 +1,56 @@ vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:3:1: error: top level declaration cannot shadow builtin type - 1 | + 1 | 2 | [inline] 3 | fn char(ch byte) fn (string) !(byte, string) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | return fn [ch] (input string) !(byte, string) { 5 | return if input[0] == ch { vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:19:18: error: unknown function: a_char - 17 | + 17 | 18 | for i, input in inputs { 19 | got, remain := a_char(input)! | ~~~~~~~~~~~~~ - 20 | + 20 | + 21 | assert got == 'a'[0] +vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:19:31: error: unexpected `!`, the function `a_char` does not return a Result + 17 | + 18 | for i, input in inputs { + 19 | got, remain := a_char(input)! + | ^ + 20 | + 21 | assert got == 'a'[0] +vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:19:15: error: assignment mismatch: 2 variable(s) but `a_char()` returns 0 value(s) + 17 | + 18 | for i, input in inputs { + 19 | got, remain := a_char(input)! + | ~~ + 20 | 21 | assert got == 'a'[0] vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:21:10: error: invalid variable `got` 19 | got, remain := a_char(input)! - 20 | + 20 | 21 | assert got == 'a'[0] | ~~~ 22 | assert remain == remains[i] 23 | } +vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:21:10: error: assert can be used only with `bool` expressions, but found `void` instead + 19 | got, remain := a_char(input)! + 20 | + 21 | assert got == 'a'[0] + | ~~~~~~~~~~~~~ + 22 | assert remain == remains[i] + 23 | } vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:22:10: error: invalid variable `remain` - 20 | + 20 | 21 | assert got == 'a'[0] 22 | assert remain == remains[i] | ~~~~~~ 23 | } 24 | } +vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:22:10: error: assert can be used only with `bool` expressions, but found `void` instead + 20 | + 21 | assert got == 'a'[0] + 22 | assert remain == remains[i] + | ~~~~~~~~~~~~~~~~~~~~ + 23 | } + 24 | } diff --git a/vlib/v/checker/tests/uncasted_enum_val_as_size_for_fixed_array_err.out b/vlib/v/checker/tests/uncasted_enum_val_as_size_for_fixed_array_err.out index 177bfd6429..02ffd53aac 100644 --- a/vlib/v/checker/tests/uncasted_enum_val_as_size_for_fixed_array_err.out +++ b/vlib/v/checker/tests/uncasted_enum_val_as_size_for_fixed_array_err.out @@ -1,13 +1,19 @@ vlib/v/checker/tests/uncasted_enum_val_as_size_for_fixed_array_err.vv:10:7: error: Foo.first has to be casted to integer to be used as size 8 | } - 9 | + 9 | 10 | a := [b]int{} | ^ 11 | println(a) 12 | vlib/v/checker/tests/uncasted_enum_val_as_size_for_fixed_array_err.vv:13:7: error: Foo.second has to be casted to integer to be used as size 11 | println(a) - 12 | + 12 | + 13 | c := [Foo.second]int{} + | ~~~~~~~~~~ + 14 | println(c) +vlib/v/checker/tests/uncasted_enum_val_as_size_for_fixed_array_err.vv:13:7: error: fixed size cannot be zero or negative (fixed_size: 0) + 11 | println(a) + 12 | 13 | c := [Foo.second]int{} | ~~~~~~~~~~ 14 | println(c) diff --git a/vlib/v/checker/tests/undefined_ident_in_ref_selector.out b/vlib/v/checker/tests/undefined_ident_in_ref_selector.out index d6f7c95f4e..ec09fd7c46 100644 --- a/vlib/v/checker/tests/undefined_ident_in_ref_selector.out +++ b/vlib/v/checker/tests/undefined_ident_in_ref_selector.out @@ -1,6 +1,25 @@ vlib/v/checker/tests/undefined_ident_in_ref_selector.vv:6:10: error: undefined ident: `line` - 4 | + 4 | 5 | fn read() int { 6 | return &line.len | ~~~~ 7 | } +vlib/v/checker/tests/undefined_ident_in_ref_selector.vv:6:15: error: `line` does not return a value + 4 | + 5 | fn read() int { + 6 | return &line.len + | ~~~ + 7 | } +vlib/v/checker/tests/undefined_ident_in_ref_selector.vv:6:9: error: cannot use `void` as type `int` in return argument + 4 | + 5 | fn read() int { + 6 | return &line.len + | ^ + 7 | } +vlib/v/checker/tests/undefined_ident_in_ref_selector.vv:6:9: error: fn `read` expects you to return a non reference type `int`, but you are returning `void` instead + 4 | + 5 | fn read() int { + 6 | return &line.len + | ^ + 7 | } +Details: use `return *pointer` instead of `return pointer`, and just `return value` instead of `return &value` diff --git a/vlib/v/checker/tests/undefined_ident_of_struct.out b/vlib/v/checker/tests/undefined_ident_of_struct.out index 35e0a6cc6c..cf44156b52 100644 --- a/vlib/v/checker/tests/undefined_ident_of_struct.out +++ b/vlib/v/checker/tests/undefined_ident_of_struct.out @@ -1,7 +1,28 @@ vlib/v/checker/tests/undefined_ident_of_struct.vv:4:2: error: undefined ident: `f` - 2 | + 2 | 3 | fn get() { 4 | f.a = 'test' | ^ 5 | } 6 | +vlib/v/checker/tests/undefined_ident_of_struct.vv:4:4: error: `f` does not return a value + 2 | + 3 | fn get() { + 4 | f.a = 'test' + | ^ + 5 | } + 6 | +vlib/v/checker/tests/undefined_ident_of_struct.vv:4:4: error: unexpected symbol `void` + 2 | + 3 | fn get() { + 4 | f.a = 'test' + | ^ + 5 | } + 6 | +vlib/v/checker/tests/undefined_ident_of_struct.vv:4:8: error: cannot assign to `f.a`: expected `void`, not `string` + 2 | + 3 | fn get() { + 4 | f.a = 'test' + | ~~~~~~ + 5 | } + 6 | diff --git a/vlib/v/checker/tests/undefined_var_in_comptime_for_test.out b/vlib/v/checker/tests/undefined_var_in_comptime_for_test.out index 0da1dc1fa9..84e65a16c2 100644 --- a/vlib/v/checker/tests/undefined_var_in_comptime_for_test.out +++ b/vlib/v/checker/tests/undefined_var_in_comptime_for_test.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/undefined_var_in_comptime_for_test.vv:11:3: error: undefine | ~~~~~~~~~~ 12 | println(field) 13 | } +vlib/v/checker/tests/undefined_var_in_comptime_for_test.vv:11:13: error: invalid operation: ++ (non-numeric type `void`) + 9 | fn test[U](val U) { + 10 | $for field in U.fields { + 11 | fields_len++ + | ~~ + 12 | println(field) + 13 | } diff --git a/vlib/v/checker/tests/unimplemented_interface_e.out b/vlib/v/checker/tests/unimplemented_interface_e.out index 8181dbb4dc..cd754406a7 100644 --- a/vlib/v/checker/tests/unimplemented_interface_e.out +++ b/vlib/v/checker/tests/unimplemented_interface_e.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/unimplemented_interface_e.vv:12:6: error: `Cat` incorrectly implements method `speak` of interface `Animal`: expected `string`, not `&string` for parameter 1 - 10 | + 10 | 11 | fn main() { 12 | foo(Cat{}) | ~~~~~ @@ -15,3 +15,9 @@ vlib/v/checker/tests/unimplemented_interface_e.vv:13:6: error: `Cat` incorrectly 14 | } Details: main.Animal has `fn speak(x main.Animal, s string)` main.Cat has `fn speak(c main.Cat, s &string)` +vlib/v/checker/tests/unimplemented_interface_e.vv:13:6: error: `Cat` does not implement interface `Animal`, cannot cast `Cat` to interface `Animal` + 11 | fn main() { + 12 | foo(Cat{}) + 13 | _ = Animal(Cat{}) + | ~~~~~~~~~~~~~ + 14 | } diff --git a/vlib/v/checker/tests/unknown_as_type.out b/vlib/v/checker/tests/unknown_as_type.out index e520655b7b..9b87dfb531 100644 --- a/vlib/v/checker/tests/unknown_as_type.out +++ b/vlib/v/checker/tests/unknown_as_type.out @@ -1,6 +1,13 @@ vlib/v/checker/tests/unknown_as_type.vv:7:9: error: unknown type `Stringg`. Did you mean `String`? - 5 | + 5 | + 6 | fn foo(e Expr) { + 7 | x := e as Stringg + | ~~ + 8 | println(x) + 9 | } +vlib/v/checker/tests/unknown_as_type.vv:7:9: error: cannot cast `Expr` to `Stringg` + 5 | 6 | fn foo(e Expr) { 7 | x := e as Stringg | ~~ diff --git a/vlib/v/checker/tests/unknown_comptime_expr.out b/vlib/v/checker/tests/unknown_comptime_expr.out index f7eb905b4f..7e25e66067 100644 --- a/vlib/v/checker/tests/unknown_comptime_expr.out +++ b/vlib/v/checker/tests/unknown_comptime_expr.out @@ -19,6 +19,20 @@ vlib/v/checker/tests/unknown_comptime_expr.vv:17:6: error: undefined ident: `huh | ~~~ 18 | } 19 | $if s is int { +vlib/v/checker/tests/unknown_comptime_expr.vv:17:10: error: `huh` does not return a value + 15 | fn if_is() { + 16 | s := S1{} + 17 | $if huh.typ is T { + | ~~~ + 18 | } + 19 | $if s is int { +vlib/v/checker/tests/unknown_comptime_expr.vv:17:17: error: unknown type `T` + 15 | fn if_is() { + 16 | s := S1{} + 17 | $if huh.typ is T { + | ^ + 18 | } + 19 | $if s is int { vlib/v/checker/tests/unknown_comptime_expr.vv:21:13: error: invalid `$if` condition: expected a type 19 | $if s is int { 20 | } diff --git a/vlib/v/checker/tests/unknown_field.out b/vlib/v/checker/tests/unknown_field.out index 395eedff82..09658bd6c8 100644 --- a/vlib/v/checker/tests/unknown_field.out +++ b/vlib/v/checker/tests/unknown_field.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/unknown_field.vv:7:12: error: type `Test` has no field name 7 | println(t.sdd) | ~~~ 8 | } +vlib/v/checker/tests/unknown_field.vv:7:2: error: `println` can not print void expressions + 5 | fn main() { + 6 | t := Test{} + 7 | println(t.sdd) + | ~~~~~~~~~~~~~~ + 8 | } diff --git a/vlib/v/checker/tests/unknown_function.out b/vlib/v/checker/tests/unknown_function.out index 8acc209fa9..caf326d2b7 100644 --- a/vlib/v/checker/tests/unknown_function.out +++ b/vlib/v/checker/tests/unknown_function.out @@ -5,3 +5,9 @@ Did you mean `math.max`? 4 | println(math.max_i64()) | ~~~~~~~~~ 5 | } +vlib/v/checker/tests/unknown_function.vv:4:2: error: `println` can not print void expressions + 2 | + 3 | fn main() { + 4 | println(math.max_i64()) + | ~~~~~~~~~~~~~~~~~~~~~~~ + 5 | } diff --git a/vlib/v/checker/tests/unknown_method.out b/vlib/v/checker/tests/unknown_method.out index 037d2f382e..15b48c69b6 100644 --- a/vlib/v/checker/tests/unknown_method.out +++ b/vlib/v/checker/tests/unknown_method.out @@ -4,3 +4,9 @@ vlib/v/checker/tests/unknown_method.vv:7:12: error: unknown method or field: `Te 7 | println(t.sdd()) | ~~~~~ 8 | } +vlib/v/checker/tests/unknown_method.vv:7:2: error: `println` can not print void expressions + 5 | fn main() { + 6 | t := Test{} + 7 | println(t.sdd()) + | ~~~~~~~~~~~~~~~~ + 8 | } diff --git a/vlib/v/checker/tests/unknown_method_suggest_name.out b/vlib/v/checker/tests/unknown_method_suggest_name.out index acf5d1427b..e1160739c6 100644 --- a/vlib/v/checker/tests/unknown_method_suggest_name.out +++ b/vlib/v/checker/tests/unknown_method_suggest_name.out @@ -14,6 +14,13 @@ Did you mean `translate`? | ~~~~~~~~~~~~ 28 | println('p: $p') 29 | println('v: $v') +vlib/v/checker/tests/unknown_method_suggest_name.vv:27:4: error: assignment mismatch: 1 variable(s) but `tranzlate()` returns 0 value(s) + 25 | p := Point{1, 2, 3} + 26 | v := Vector{x: 5, y: 5, z: 10} + 27 | z := p.tranzlate(v) + | ~~ + 28 | println('p: $p') + 29 | println('v: $v') vlib/v/checker/tests/unknown_method_suggest_name.vv:30:15: error: expression does not return a value 28 | println('p: $p') 29 | println('v: $v') diff --git a/vlib/v/checker/tests/unknown_var_assign.out b/vlib/v/checker/tests/unknown_var_assign.out index 6a12a8cbbc..dc1867dd1e 100644 --- a/vlib/v/checker/tests/unknown_var_assign.out +++ b/vlib/v/checker/tests/unknown_var_assign.out @@ -3,3 +3,8 @@ vlib/v/checker/tests/unknown_var_assign.vv:2:5: error: undefined ident: `x` (use 2 | x = 'hello v' | ^ 3 | } +vlib/v/checker/tests/unknown_var_assign.vv:2:9: error: cannot assign to `x`: expected `void`, not `string` + 1 | fn main() { + 2 | x = 'hello v' + | ~~~~~~~~~ + 3 | } diff --git a/vlib/v/checker/tests/var_option_wrong_type.out b/vlib/v/checker/tests/var_option_wrong_type.out index ce1a755fbd..532bdf75a9 100644 --- a/vlib/v/checker/tests/var_option_wrong_type.out +++ b/vlib/v/checker/tests/var_option_wrong_type.out @@ -4,3 +4,15 @@ vlib/v/checker/tests/var_option_wrong_type.vv:3:23: error: mismatched types `?f6 3 | var3 := var_none or { var_none + 'foo' } | ~~~~~~~~~~~~~~~~ 4 | println(var3) +vlib/v/checker/tests/var_option_wrong_type.vv:3:23: error: infix expr: cannot use `string` (right expression) as `f64` + 1 | var_none := ?f64(none) + 2 | + 3 | var3 := var_none or { var_none + 'foo' } + | ~~~~~~~~~~~~~~~~ + 4 | println(var3) +vlib/v/checker/tests/var_option_wrong_type.vv:3:23: error: `or` block must provide a default value of type `f64`, or return/continue/break or call a [noreturn] function like panic(err) or exit(1) + 1 | var_none := ?f64(none) + 2 | + 3 | var3 := var_none or { var_none + 'foo' } + | ~~~~~~~~~~~~~~~~ + 4 | println(var3) diff --git a/vlib/v/checker/tests/void_fn_as_value.out b/vlib/v/checker/tests/void_fn_as_value.out index 9898c195be..f44853ec75 100644 --- a/vlib/v/checker/tests/void_fn_as_value.out +++ b/vlib/v/checker/tests/void_fn_as_value.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/void_fn_as_value.vv:5:7: error: unknown function: x | ~~~~~~~~~~ 6 | mut b := 'abcdef' 7 | _ = b +vlib/v/checker/tests/void_fn_as_value.vv:5:4: error: assignment mismatch: 1 variable(s) but `x()` returns 0 value(s) + 3 | fn main() { + 4 | mut a := 'aa' + 5 | a += x('a','b') + | ~~ + 6 | mut b := 'abcdef' + 7 | _ = b diff --git a/vlib/v/checker/tests/void_fn_multiple_ret_err.out b/vlib/v/checker/tests/void_fn_multiple_ret_err.out index 24af8247e0..13431f8e13 100644 --- a/vlib/v/checker/tests/void_fn_multiple_ret_err.out +++ b/vlib/v/checker/tests/void_fn_multiple_ret_err.out @@ -11,6 +11,13 @@ vlib/v/checker/tests/void_fn_multiple_ret_err.vv:6:2: error: Option and Result t | ~~~~~~~~~~~ 7 | } 8 | +vlib/v/checker/tests/void_fn_multiple_ret_err.vv:6:9: error: cannot use `none` as Result type in return argument + 4 | + 5 | fn foo_result_2() ! { + 6 | return none + | ~~~~ + 7 | } + 8 | vlib/v/checker/tests/void_fn_multiple_ret_err.vv:14:9: error: cannot use `int literal` as Result type in return argument 12 | 13 | fn foo_result_4() ! { diff --git a/vlib/v/checker/tests/warnings_for_string_c2v_calls.out b/vlib/v/checker/tests/warnings_for_string_c2v_calls.out index f570847a42..e87d1aabd6 100644 --- a/vlib/v/checker/tests/warnings_for_string_c2v_calls.out +++ b/vlib/v/checker/tests/warnings_for_string_c2v_calls.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/warnings_for_string_c2v_calls.vv:8:7: error: to convert a C | ~~~~~~~~~ 9 | eprintln('x: $x') 10 | eprintln('x.len: $x.len') +vlib/v/checker/tests/warnings_for_string_c2v_calls.vv:8:7: error: cannot cast pointer type `&u8` to string, use `&u8(p).vstring()` or `cstring_to_vstring(p)` instead. + 6 | p[2] = `z` + 7 | } + 8 | x := string(p) + | ~~~~~~~~~ + 9 | eprintln('x: $x') + 10 | eprintln('x.len: $x.len') diff --git a/vlib/v/checker/tests/with_check_option/v_tictactoe.out b/vlib/v/checker/tests/with_check_option/v_tictactoe.out index 8682a24390..6c5cc73b39 100644 --- a/vlib/v/checker/tests/with_check_option/v_tictactoe.out +++ b/vlib/v/checker/tests/with_check_option/v_tictactoe.out @@ -31,3 +31,10 @@ vlib/v/checker/tests/with_check_option/v_tictactoe.vv:6:14: error: unknown type | ~~~~~~~ 7 | } 8 | return board +vlib/v/checker/tests/with_check_option/v_tictactoe.vv:6:21: error: unknown type for expression `board[i / 3]` + 4 | mut board := [3][]string{ len: 3, init: []string{ len: 3, init: '' } } + 5 | for i in 0..9 { + 6 | board[i / 3][i % 3] = (i + 1).str() + | ~~~~~~~ + 7 | } + 8 | return board diff --git a/vlib/v/checker/tests/wrong_fn_init_err.out b/vlib/v/checker/tests/wrong_fn_init_err.out index 15aff9f9ae..489c1bf089 100644 --- a/vlib/v/checker/tests/wrong_fn_init_err.out +++ b/vlib/v/checker/tests/wrong_fn_init_err.out @@ -5,3 +5,10 @@ vlib/v/checker/tests/wrong_fn_init_err.vv:4:7: error: functions must be defined, | ~~~~~~~~~~~~ 5 | println(a) 6 | } +vlib/v/checker/tests/wrong_fn_init_err.vv:4:7: error: type `MyCallback` is private + 2 | + 3 | fn main() { + 4 | a := MyCallback{} + | ~~~~~~~~~~~~ + 5 | println(a) + 6 | } diff --git a/vlib/v/checker/tests/wrong_propagate_ret_type.out b/vlib/v/checker/tests/wrong_propagate_ret_type.out index 9687026366..1fcd559699 100644 --- a/vlib/v/checker/tests/wrong_propagate_ret_type.out +++ b/vlib/v/checker/tests/wrong_propagate_ret_type.out @@ -1,5 +1,5 @@ vlib/v/checker/tests/wrong_propagate_ret_type.vv:10:17: error: to propagate the Option call, `opt_call` must return an Option - 8 | + 8 | 9 | fn opt_call() int { 10 | a := ret_none()? | ^ @@ -7,13 +7,27 @@ vlib/v/checker/tests/wrong_propagate_ret_type.vv:10:17: error: to propagate the 12 | } Details: vlib/v/checker/tests/wrong_propagate_ret_type.vv:9:15: details: prepend ? before the declaration of the return type of `opt_call` 7 | } - 8 | + 8 | + 9 | fn opt_call() int { + | ~~~ + 10 | a := ret_none()? + 11 | return a +vlib/v/checker/tests/wrong_propagate_ret_type.vv:10:17: error: to propagate the call, `opt_call` must return an Option type + 8 | + 9 | fn opt_call() int { + 10 | a := ret_none()? + | ^ + 11 | return a + 12 | } +Details: vlib/v/checker/tests/wrong_propagate_ret_type.vv:9:15: details: prepend ? before the declaration of the return type of `opt_call` + 7 | } + 8 | 9 | fn opt_call() int { | ~~~ 10 | a := ret_none()? 11 | return a vlib/v/checker/tests/wrong_propagate_ret_type.vv:15:17: error: to propagate the Result call, `res_call` must return a Result - 13 | + 13 | 14 | fn res_call() bool { 15 | a := ret_bool()! | ^ @@ -21,8 +35,15 @@ vlib/v/checker/tests/wrong_propagate_ret_type.vv:15:17: error: to propagate the 17 | } Details: vlib/v/checker/tests/wrong_propagate_ret_type.vv:14:15: details: prepend ! before the declaration of the return type of `res_call` 12 | } - 13 | + 13 | 14 | fn res_call() bool { | ~~~~ 15 | a := ret_bool()! - 16 | return a \ No newline at end of file + 16 | return a +vlib/v/checker/tests/wrong_propagate_ret_type.vv:15:17: error: unexpected `!`, the function `ret_bool` does not return a Result + 13 | + 14 | fn res_call() bool { + 15 | a := ret_bool()! + | ^ + 16 | return a + 17 | } diff --git a/vlib/v/parser/tests/closure_not_declared.out b/vlib/v/parser/tests/closure_not_declared.out index 093797970c..6dd240a56f 100644 --- a/vlib/v/parser/tests/closure_not_declared.out +++ b/vlib/v/parser/tests/closure_not_declared.out @@ -5,3 +5,17 @@ vlib/v/parser/tests/closure_not_declared.vv:4:9: error: `a` must be added to the | ^ 5 | } 6 | f() +vlib/v/parser/tests/closure_not_declared.vv:4:3: error: `print` can not print void expressions + 2 | a := 1 + 3 | f := fn () { + 4 | print(a) + | ~~~~~~~~ + 5 | } + 6 | f() +vlib/v/parser/tests/closure_not_declared.vv:4:9: error: undefined ident: `a` + 2 | a := 1 + 3 | f := fn () { + 4 | print(a) + | ^ + 5 | } + 6 | f() diff --git a/vlib/v/parser/tests/expected_type_enum_err.out b/vlib/v/parser/tests/expected_type_enum_err.out index e378cf7d2d..0ca271e2bf 100644 --- a/vlib/v/parser/tests/expected_type_enum_err.out +++ b/vlib/v/parser/tests/expected_type_enum_err.out @@ -1,6 +1,12 @@ vlib/v/parser/tests/expected_type_enum_err.vv:6:12: error: expected type is not an enum (`rune`) - 4 | + 4 | 5 | fn main() { 6 | if `c` == .bar {} | ~~~~ - 7 | } \ No newline at end of file + 7 | } +vlib/v/parser/tests/expected_type_enum_err.vv:6:5: error: non-bool type `void` used as if condition + 4 | + 5 | fn main() { + 6 | if `c` == .bar {} + | ~~~~~~~~~~~ + 7 | } diff --git a/vlib/v/parser/tests/method_call_receiver_err.out b/vlib/v/parser/tests/method_call_receiver_err.out index 0351a23083..7f54eca232 100644 --- a/vlib/v/parser/tests/method_call_receiver_err.out +++ b/vlib/v/parser/tests/method_call_receiver_err.out @@ -19,3 +19,10 @@ vlib/v/parser/tests/method_call_receiver_err.vv:9:11: error: unknown function: S | ~~~~~~~~~~~~~~~~~~~~~ 10 | } 11 | } +vlib/v/parser/tests/method_call_receiver_err.vv:9:3: error: `println` can not print void expressions + 7 | + 8 | $for method in S1.methods { + 9 | println(S1.method_hello('yo')) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 10 | } + 11 | } diff --git a/vlib/v/scanner/tests/undefined_ident_in_string_literal_err.out b/vlib/v/scanner/tests/undefined_ident_in_string_literal_err.out index b6054ac8f0..7d8c72cf60 100644 --- a/vlib/v/scanner/tests/undefined_ident_in_string_literal_err.out +++ b/vlib/v/scanner/tests/undefined_ident_in_string_literal_err.out @@ -4,3 +4,9 @@ vlib/v/scanner/tests/undefined_ident_in_string_literal_err.vv:2:15: error: undef | ~~~~ 3 | } 4 | +vlib/v/scanner/tests/undefined_ident_in_string_literal_err.vv:2:15: error: expression does not return a value + 1 | fn abc() string { + 2 | return 'abc $type' + | ~~~~ + 3 | } + 4 | diff --git a/vlib/v/slow_tests/repl/error.repl b/vlib/v/slow_tests/repl/error.repl index e85d252f99..68136316c4 100644 --- a/vlib/v/slow_tests/repl/error.repl +++ b/vlib/v/slow_tests/repl/error.repl @@ -5,3 +5,8 @@ error: undefined ident: `a` 6 | 7 | println(a) | ^ +error: `println` can not print void expressions + 5 | import math + 6 | + 7 | println(a) + | ~~~~~~~~~~ diff --git a/vlib/v/slow_tests/repl/error_and_continue_print.repl b/vlib/v/slow_tests/repl/error_and_continue_print.repl index 3cfc0bfbf6..253f7f18fe 100644 --- a/vlib/v/slow_tests/repl/error_and_continue_print.repl +++ b/vlib/v/slow_tests/repl/error_and_continue_print.repl @@ -7,9 +7,19 @@ error: undefined ident: `a` (use `:=` to declare a variable) 6 | 7 | a = 3 | ^ +error: cannot assign to `a`: expected `void`, not `int literal` + 5 | import math + 6 | + 7 | a = 3 + | ^ error: undefined ident: `b` 5 | import math 6 | 7 | println(b) | ^ +error: `println` can not print void expressions + 5 | import math + 6 | + 7 | println(b) + | ~~~~~~~~~~ [4] diff --git a/vlib/v/slow_tests/repl/error_exitasdfasdf.repl b/vlib/v/slow_tests/repl/error_exitasdfasdf.repl index a026a8ee1a..1ab0f356c2 100644 --- a/vlib/v/slow_tests/repl/error_exitasdfasdf.repl +++ b/vlib/v/slow_tests/repl/error_exitasdfasdf.repl @@ -5,3 +5,8 @@ error: undefined ident: `exitasdfasdf` 6 | 7 | println(exitasdfasdf) | ~~~~~~~~~~~~ +error: `println` can not print void expressions + 5 | import math + 6 | + 7 | println(exitasdfasdf) + | ~~~~~~~~~~~~~~~~~~~~~