diff --git a/vlib/os/os_windows.c.v b/vlib/os/os_windows.c.v index 858aeede3f..5f6d3d347a 100644 --- a/vlib/os/os_windows.c.v +++ b/vlib/os/os_windows.c.v @@ -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]) } } diff --git a/vlib/v/checker/check_types.v b/vlib/v/checker/check_types.v index acf11ede83..6b0e34a176 100644 --- a/vlib/v/checker/check_types.v +++ b/vlib/v/checker/check_types.v @@ -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() { diff --git a/vlib/v/checker/tests/store_string_err.out b/vlib/v/checker/tests/store_string_err.out new file mode 100644 index 0000000000..b0a44bfb49 --- /dev/null +++ b/vlib/v/checker/tests/store_string_err.out @@ -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) diff --git a/vlib/v/checker/tests/store_string_err.vv b/vlib/v/checker/tests/store_string_err.vv new file mode 100644 index 0000000000..7f8b3ff29a --- /dev/null +++ b/vlib/v/checker/tests/store_string_err.vv @@ -0,0 +1,6 @@ +fn return_err() ?int { + return error('') +} + +err := return_err() or { err } +eprintln(err) diff --git a/vlib/v/pkgconfig/pkgconfig_test.v b/vlib/v/pkgconfig/pkgconfig_test.v index f316ce19df..4bc0db6191 100644 --- a/vlib/v/pkgconfig/pkgconfig_test.v +++ b/vlib/v/pkgconfig/pkgconfig_test.v @@ -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'] diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index d4ac45abfa..259954feb9 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -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{ diff --git a/vlib/v/tests/repl/runner/runner.v b/vlib/v/tests/repl/runner/runner.v index 482d8d03c6..54376765fe 100644 --- a/vlib/v/tests/repl/runner/runner.v +++ b/vlib/v/tests/repl/runner/runner.v @@ -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) }