mirror of
https://github.com/vlang/v.git
synced 2025-09-15 18:36:37 -04:00
checker: extract vlib/v/checker/errors.v, use maps for c.error_lines, c.warning_lines, c.notice_lines, dedup all errors, warns, and notices
To better support projects with lots of errors/notices, deduplicate notices, warnings and messages, for the same line (`generic method routes of vweb will be skipped` etc).
This commit is contained in:
parent
13c9006667
commit
1512486d01
@ -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)
|
||||
|
195
vlib/v/checker/errors.v
Normal file
195
vlib/v/checker/errors.v
Normal file
@ -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}'
|
||||
}
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 |
|
||||
|
@ -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 |
|
||||
|
@ -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
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
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 | }
|
||||
|
@ -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 | }
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 | }
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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 |
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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)
|
||||
|
@ -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{}
|
||||
|
@ -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{}
|
||||
|
@ -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'
|
||||
|
@ -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 |
|
||||
|
@ -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 |
|
||||
|
@ -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
|
||||
| ~~~~~
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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')
|
||||
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')
|
||||
|
@ -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 | }
|
||||
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 | }
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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 | }
|
||||
|
@ -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'
|
||||
|
@ -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 | }
|
||||
|
@ -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)
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 {
|
||||
|
@ -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 | }
|
||||
|
@ -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)
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
48 | }
|
||||
|
@ -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)
|
||||
| ~~~~~
|
||||
| ~~~~~
|
||||
|
@ -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 | }
|
||||
|
@ -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)
|
||||
|
@ -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 | }
|
||||
5 | }
|
||||
|
@ -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 |
|
||||
|
@ -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 |
|
||||
|
@ -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 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 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 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 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 U) []P {
|
||||
| ~~~
|
||||
36 | return [P{}]
|
||||
|
@ -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 | }
|
||||
|
@ -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)
|
||||
| ~~~~~~~~~~~~
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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 {
|
||||
|
@ -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<int>(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<int, int, string>(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<int, int, string>(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<int>(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<int, int, string>(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<int, int, string>(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, B>(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, B>(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, B>(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, B>(a A, b B) string {
|
||||
8 | return '$a, $b'
|
||||
| ^
|
||||
9 | }
|
||||
10 |
|
||||
|
@ -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{
|
||||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -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 {
|
||||
|
@ -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<A, B>(res A, b B) string {
|
||||
6 | msg := Response<U>{
|
||||
| ~~~~~~~~~~~~
|
||||
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<A, B>(res A, b B) string {
|
||||
14 | msg := Response<A, B>{
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
@ -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 | ]
|
||||
|
@ -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 | }
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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 | }
|
||||
|
@ -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
|
||||
| ^
|
||||
|
@ -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
|
||||
| ^
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 _
|
||||
|
@ -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 {}
|
||||
|
@ -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) }
|
||||
| ~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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
|
||||
|
@ -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 | }
|
||||
|
@ -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)
|
||||
| ~~~~~~~~~
|
||||
|
@ -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 |
|
||||
|
@ -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 |
|
||||
|
@ -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
|
||||
| ^
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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 | }
|
||||
|
@ -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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user