From da68b2d3691ad53fba1bb64385f0cb6147251e38 Mon Sep 17 00:00:00 2001 From: Swastik Baranwal Date: Thu, 5 Jan 2023 19:11:18 +0530 Subject: [PATCH] checker: remove `c.pref.is_test` exception for calling private methods in _other_ modules (#16872) --- vlib/cli/flag.v | 2 +- vlib/regex/regex.v | 2 +- vlib/toml/tests/encode_and_decode_test.v | 4 ++-- vlib/v/ast/cflags.v | 2 +- vlib/v/checker/fn.v | 2 +- vlib/vweb/assets/assets.v | 2 +- vlib/x/json2/decoder.v | 3 ++- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/vlib/cli/flag.v b/vlib/cli/flag.v index 1419353a7..dfd08602a 100644 --- a/vlib/cli/flag.v +++ b/vlib/cli/flag.v @@ -211,7 +211,7 @@ pub fn (flags []Flag) get_strings(name string) ![]string { // parse parses flag values from arguments and return // an array of arguments with all consumed elements removed. -fn (mut flag Flag) parse(args []string, posix_mode bool) ![]string { +pub fn (mut flag Flag) parse(args []string, posix_mode bool) ![]string { if flag.matches(args, posix_mode) { if flag.flag == .bool { new_args := flag.parse_bool(args)! diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index 099011964..ea939d2d2 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -321,7 +321,7 @@ pub mut: // Reset RE object [direct_array_access; inline] -fn (mut re RE) reset() { +pub fn (mut re RE) reset() { re.cc_index = 0 mut i := 0 diff --git a/vlib/toml/tests/encode_and_decode_test.v b/vlib/toml/tests/encode_and_decode_test.v index eb5151e07..12ab0b6cb 100644 --- a/vlib/toml/tests/encode_and_decode_test.v +++ b/vlib/toml/tests/encode_and_decode_test.v @@ -15,7 +15,7 @@ pub mut: title JobTitle } -fn (e Employee) to_toml() string { +pub fn (e Employee) to_toml() string { mut mp := map[string]toml.Any{} mp['name'] = toml.Any(e.name) mp['age'] = toml.Any(e.age) @@ -25,7 +25,7 @@ fn (e Employee) to_toml() string { return mp.to_toml() } -fn (mut e Employee) from_toml(any toml.Any) { +pub fn (mut e Employee) from_toml(any toml.Any) { mp := any.as_map() e.name = mp['name'] or { toml.Any('') }.string() e.age = mp['age'] or { toml.Any(0) }.int() diff --git a/vlib/v/ast/cflags.v b/vlib/v/ast/cflags.v index a1f7ba6b2..fac0a771a 100644 --- a/vlib/v/ast/cflags.v +++ b/vlib/v/ast/cflags.v @@ -6,7 +6,7 @@ module ast import v.cflag // check if cflag is in table -fn (t &Table) has_cflag(flag cflag.CFlag) bool { +pub fn (t &Table) has_cflag(flag cflag.CFlag) bool { for cf in t.cflags { if cf.os == flag.os && cf.name == flag.name && cf.value == flag.value { return true diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index dcc1073bb..059a664ac 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -1502,7 +1502,7 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type { node.is_noreturn = method.is_noreturn node.is_ctor_new = method.is_ctor_new node.return_type = method.return_type - if !method.is_pub && !c.pref.is_test && method.mod != c.mod { + if !method.is_pub && method.mod != c.mod { // If a private method is called outside of the module // its receiver type is defined in, show an error. // println('warn $method_name lef.mod=$left_type_sym.mod c.mod=$c.mod') diff --git a/vlib/vweb/assets/assets.v b/vlib/vweb/assets/assets.v index 02197a66c..de67ed661 100644 --- a/vlib/vweb/assets/assets.v +++ b/vlib/vweb/assets/assets.v @@ -143,7 +143,7 @@ fn (am AssetManager) include(asset_type string, combine bool) string { // dont return option until size limit is removed // fn (mut am AssetManager) add(asset_type, file string) ?bool { -fn (mut am AssetManager) add(asset_type string, file string) bool { +pub fn (mut am AssetManager) add(asset_type string, file string) bool { if !os.exists(file) { // return error('vweb.assets: cannot add asset $file, it does not exist') return false diff --git a/vlib/x/json2/decoder.v b/vlib/x/json2/decoder.v index 494a4e5a0..a3390bb86 100644 --- a/vlib/x/json2/decoder.v +++ b/vlib/x/json2/decoder.v @@ -113,7 +113,8 @@ fn new_parser(srce string, convert_type bool) Parser { } } -fn (mut p Parser) decode() !Any { +// decode decodes provided JSON +pub fn (mut p Parser) decode() !Any { p.next() p.next_with_err()! fi := p.decode_value()! -- 2.30.2