Skip to content

Commit

Permalink
builtin, checker: fix aliases of u8 array clone() call (#20393)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Jan 5, 2024
1 parent e19b2dd commit bfe2cb7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
10 changes: 0 additions & 10 deletions vlib/builtin/int.v
Expand Up @@ -574,16 +574,6 @@ pub fn (c u8) is_capital() bool {
return c >= `A` && c <= `Z`
}

// clone clones the byte array, and returns the newly created copy.
pub fn (b []u8) clone() []u8 {
mut res := []u8{len: b.len}
// mut res := make([]u8, {repeat:b.len})
for i in 0 .. b.len {
res[i] = b[i]
}
return res
}

// bytestr produces a string from *all* the bytes in the array.
// Note: the returned string will have .len equal to the array.len,
// even when some of the array bytes were `0`.
Expand Down
3 changes: 1 addition & 2 deletions vlib/v/checker/fn.v
Expand Up @@ -1742,8 +1742,7 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
}
if final_left_sym.kind == .array {
if array_builtin_methods_chk.matches(method_name) && (left_sym.kind == .array
|| (left_sym.kind == .alias && method_name != 'clone'
&& !left_sym.has_method(method_name))) {
|| (left_sym.kind == .alias && !left_sym.has_method(method_name))) {
return c.array_builtin_method_call(mut node, left_type)
} else if method_name in ['insert', 'prepend'] {
if method_name == 'insert' {
Expand Down

0 comments on commit bfe2cb7

Please sign in to comment.