Skip to content

Commit

Permalink
more cleanup in method_call()
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Oct 24, 2024
1 parent 6b73fb9 commit b96660c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b96660c

Please sign in to comment.