mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: string != IError (#10665)
This commit is contained in:
parent
6aecda3be8
commit
da9c75f2ca
@ -485,7 +485,7 @@ pub fn hostname() string {
|
||||
size := u32(255)
|
||||
res := C.GetComputerNameW(&hostname[0], &size)
|
||||
if !res {
|
||||
return error(get_error_msg(int(C.GetLastError())))
|
||||
return get_error_msg(int(C.GetLastError()))
|
||||
}
|
||||
return unsafe { string_from_wide(&hostname[0]) }
|
||||
}
|
||||
@ -495,7 +495,7 @@ pub fn loginname() string {
|
||||
size := u32(255)
|
||||
res := C.GetUserNameW(&loginname[0], &size)
|
||||
if !res {
|
||||
return error(get_error_msg(int(C.GetLastError())))
|
||||
return get_error_msg(int(C.GetLastError()))
|
||||
}
|
||||
return unsafe { string_from_wide(&loginname[0]) }
|
||||
}
|
||||
|
@ -130,10 +130,6 @@ pub fn (mut c Checker) check_basic(got ast.Type, expected ast.Type) bool {
|
||||
if got_sym.kind == .function && exp_sym.kind == .function {
|
||||
return c.check_matching_function_symbols(got_sym, exp_sym)
|
||||
}
|
||||
// allow using Error as a string for now (avoid a breaking change)
|
||||
if got == ast.error_type_idx && expected == ast.string_type_idx {
|
||||
return true
|
||||
}
|
||||
// allow `return 0` in a function with `?int` return type
|
||||
expected_nonflagged := expected.clear_flags()
|
||||
if got == ast.int_literal_type && expected_nonflagged.is_int() {
|
||||
|
6
vlib/v/checker/tests/store_string_err.out
Normal file
6
vlib/v/checker/tests/store_string_err.out
Normal file
@ -0,0 +1,6 @@
|
||||
vlib/v/checker/tests/store_string_err.vv:5:26: error: wrong return type `IError` in the `or {}` block, expected `int`
|
||||
3 | }
|
||||
4 |
|
||||
5 | err := return_err() or { err }
|
||||
| ~~~
|
||||
6 | eprintln(err)
|
6
vlib/v/checker/tests/store_string_err.vv
Normal file
6
vlib/v/checker/tests/store_string_err.vv
Normal file
@ -0,0 +1,6 @@
|
||||
fn return_err() ?int {
|
||||
return error('')
|
||||
}
|
||||
|
||||
err := return_err() or { err }
|
||||
eprintln(err)
|
@ -21,7 +21,7 @@ fn test_dependency_resolution_fails_correctly() {
|
||||
mut errors := []string{}
|
||||
for pc in pc_files {
|
||||
pcname := os.file_name(pc).replace('.pc', '')
|
||||
pkgconfig.load(pcname, use_default_paths: false, path: samples_dir) or { errors << err }
|
||||
pkgconfig.load(pcname, use_default_paths: false, path: samples_dir) or { errors << err.msg }
|
||||
}
|
||||
assert errors.len < pc_files.len
|
||||
assert errors == ['could not resolve dependency xyz-unknown-package']
|
||||
|
@ -106,7 +106,7 @@ pub fn new_scanner_file(file_path string, comments_mode CommentsMode, pref &pref
|
||||
verror("$file_path doesn't exist")
|
||||
}
|
||||
raw_text := util.read_file(file_path) or {
|
||||
verror(err)
|
||||
verror(err.msg)
|
||||
return voidptr(0)
|
||||
}
|
||||
mut s := &Scanner{
|
||||
|
@ -35,7 +35,7 @@ pub fn full_path_to_v(dirs_in int) string {
|
||||
}
|
||||
|
||||
fn diff_files(file_result string, file_expected string) string {
|
||||
diffcmd := diff.find_working_diff_command() or { return err }
|
||||
diffcmd := diff.find_working_diff_command() or { return err.msg }
|
||||
return diff.color_compare_files(diffcmd, file_result, file_expected)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user