builtin, checker: fix aliases of u8 array clone() call (#20393)

This commit is contained in:
yuyi 2024-01-05 17:56:19 +08:00 committed by GitHub
parent e19b2dd46f
commit bfe2cb7d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 12 deletions

View File

@ -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`.

View File

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