From 481f103dc99c4128fc8dcce18b122f0d6872a46d Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 27 May 2020 12:00:08 +0300 Subject: [PATCH] checker: make an error using non `pub` fns from other modules --- vlib/builtin/string.v | 5 +---- vlib/v/checker/checker.v | 5 ++--- vlib/v/util/errors.v | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 65af029ca6..a4aa301953 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -940,10 +940,7 @@ pub fn (s string) trim_suffix(str string) string { return s } -// fn print_cur_thread() { -// //C.printf("tid = %08x \n", pthread_self()); -// } -fn compare_strings(a, b &string) int { +pub fn compare_strings(a, b &string) int { if a.lt(b) { return -1 } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 22d5bb2dfa..524af0d416 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -911,9 +911,8 @@ pub fn (mut c Checker) call_fn(mut call_expr ast.CallExpr) table.Type { call_expr.pos) } } - if !f.is_pub && f.language == .v && !c.is_builtin_mod && !c.pref.is_test && f.mod != c.mod && - f.name != '' && f.mod != '' { - c.warn('function `$f.name` is private. curmod=$c.mod fmod=$f.mod', call_expr.pos) + if !f.is_pub && f.language == .v && f.name.len > 0 && f.mod.len > 0 && f.mod != c.mod { + c.error('function `$f.name` is private. curmod=$c.mod fmod=$f.mod', call_expr.pos) } call_expr.return_type = f.return_type if f.return_type == table.void_type && f.ctdefine.len > 0 && f.ctdefine !in c.pref.compile_defines { diff --git a/vlib/v/util/errors.v b/vlib/v/util/errors.v index 3b34f1cf67..bc0778761a 100644 --- a/vlib/v/util/errors.v +++ b/vlib/v/util/errors.v @@ -174,7 +174,7 @@ pub fn color_compare_files(diff_cmd, file1, file2 string) string { return '' } -fn color_compare_strings(diff_cmd string, expected string, found string) string { +pub fn color_compare_strings(diff_cmd string, expected string, found string) string { cdir := os.cache_dir() ctime := time.sys_mono_now() e_file := os.join_path(cdir, '${ctime}.expected.txt')