1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: use array_builtin_methods_chk.matches(method_name) instead of method_name in array_builtin_methods

This commit is contained in:
Delyan Angelov 2022-07-29 23:02:33 +03:00
parent 336305daa5
commit f0a8d57735
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 3 additions and 1 deletions

View File

@ -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'
)

View File

@ -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'] {