checker: fix generic_mutable_arrays in functions (#8445)
parent
64d12cdc8d
commit
c5e7956eb5
|
@ -1359,3 +1359,12 @@ fn test_clone_of_same_elem_size_array() {
|
|||
println(arr2)
|
||||
assert arr2 == [Abc{1, 2, 3}, Abc{2, 3, 4}]
|
||||
}
|
||||
|
||||
pub fn example<T>(mut arr []T) []T {
|
||||
return arr.clone()
|
||||
}
|
||||
|
||||
fn test_generic_mutable_arrays() {
|
||||
mut arr := [1, 2, 3]
|
||||
assert example(mut arr) == [1, 2, 3]
|
||||
}
|
||||
|
|
|
@ -1356,7 +1356,7 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
|||
// need to return `array_xxx` instead of `array`
|
||||
// in ['clone', 'str'] {
|
||||
call_expr.receiver_type = left_type.to_ptr()
|
||||
// call_expr.return_type = call_expr.receiver_type
|
||||
call_expr.return_type = call_expr.receiver_type.set_nr_muls(0)
|
||||
} else if method_name == 'sort' {
|
||||
call_expr.return_type = table.void_type
|
||||
} else if method_name == 'contains' {
|
||||
|
|
Loading…
Reference in New Issue