From b96660cd5a11d57127d1d28744572c221b06bd82 Mon Sep 17 00:00:00 2001 From: yuyi Date: Thu, 24 Oct 2024 10:48:00 +0800 Subject: [PATCH] more cleanup in method_call() --- vlib/v/checker/checker.v | 2 ++ vlib/v/checker/fn.v | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index d93403406fcd7c..a19ef8b7e84260 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -32,6 +32,8 @@ pub const array_builtin_methods = ['filter', 'clone', 'repeat', 'reverse', 'map' 'sort_with_compare', 'sorted', 'sorted_with_compare', 'contains', 'index', 'wait', 'any', 'all', 'first', 'last', 'pop', 'delete', 'insert', 'prepend'] pub const array_builtin_methods_chk = token.new_keywords_matcher_from_array_trie(array_builtin_methods) +pub const fixed_array_builtin_methods = ['contains', 'index', 'any', 'all', 'wait', 'map', 'sort'] +pub const fixed_array_builtin_methods_chk = token.new_keywords_matcher_from_array_trie(fixed_array_builtin_methods) // TODO: remove `byte` from this list when it is no longer supported pub const reserved_type_names = ['byte', 'bool', 'char', 'i8', 'i16', 'int', 'i64', 'u8', 'u16', 'u32', 'u64', 'f32', 'f64', 'map', 'string', 'rune', 'usize', 'isize', 'voidptr', 'thread'] diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 0bcc9e72e35ca9..5406a8b93a48dd 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -2065,7 +2065,7 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type { && !(left_sym.kind == .alias && left_sym.has_method(method_name)) { return c.array_builtin_method_call(mut node, left_type) } else if final_left_sym.kind == .array_fixed - && method_name in ['contains', 'index', 'all', 'any', 'wait'] && !(left_sym.kind == .alias + && fixed_array_builtin_methods_chk.matches(method_name) && !(left_sym.kind == .alias && left_sym.has_method(method_name)) { return c.fixed_array_builtin_method_call(mut node, left_type) } else if final_left_sym.kind == .map