From f0a8d57735fa40ab1cd2e76b20f84212b03a2740 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 29 Jul 2022 23:02:33 +0300 Subject: [PATCH] checker: use `array_builtin_methods_chk.matches(method_name)` instead of `method_name in array_builtin_methods` --- 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 444b18d2f3..7c9ceb6b90 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -36,9 +36,11 @@ pub const ( valid_comptime_not_user_defined = all_valid_comptime_idents() array_builtin_methods = ['filter', 'clone', 'repeat', 'reverse', 'map', 'slice', 'sort', 'contains', 'index', 'wait', 'any', 'all', 'first', 'last', 'pop'] + array_builtin_methods_chk = token.new_keywords_matcher_from_array_trie(array_builtin_methods) // TODO: remove `byte` from this list when it is no longer supported reserved_type_names = ['byte', 'bool', 'char', 'i8', 'i16', 'int', 'i64', 'u8', 'u16', 'u32', 'u64', 'f32', 'f64', 'map', 'string', 'rune'] + reserved_type_names_chk = token.new_keywords_matcher_from_array_trie(reserved_type_names) vroot_is_deprecated_message = '@VROOT is deprecated, use @VMODROOT or @VEXEROOT instead' ) diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index c182e9e6e3..3994c403c5 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -1154,7 +1154,7 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type { } // TODO: remove this for actual methods, use only for compiler magic // FIXME: Argument count != 1 will break these - if left_sym.kind == .array && method_name in array_builtin_methods { + if left_sym.kind == .array && array_builtin_methods_chk.matches(method_name) { return c.array_builtin_method_call(mut node, left_type, c.table.sym(left_type)) } else if (left_sym.kind == .map || final_left_sym.kind == .map) && method_name in ['clone', 'keys', 'values', 'move', 'delete'] {