mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix sort return type (#6182)
This commit is contained in:
parent
e8ff94fb8b
commit
0c183da116
@ -910,6 +910,8 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
||||
// in ['clone', 'str'] {
|
||||
call_expr.receiver_type = left_type.to_ptr()
|
||||
// call_expr.return_type = call_expr.receiver_type
|
||||
} else if method_name == 'sort' {
|
||||
call_expr.return_type = table.void_type
|
||||
}
|
||||
return call_expr.return_type
|
||||
} else if left_type_sym.kind == .map && method_name == 'clone' {
|
||||
|
@ -3907,14 +3907,14 @@ fn (mut g Gen) gen_array_map(node ast.CallExpr) {
|
||||
// `users.sort(a.age < b.age)`
|
||||
fn (mut g Gen) gen_array_sort(node ast.CallExpr) {
|
||||
// println('filter s="$s"')
|
||||
return_sym := g.table.get_type_symbol(node.return_type)
|
||||
if return_sym.kind != .array {
|
||||
rec_sym := g.table.get_type_symbol(node.receiver_type)
|
||||
if rec_sym.kind != .array {
|
||||
println(node.name)
|
||||
println(g.typ(node.receiver_type))
|
||||
// println(sym.kind)
|
||||
verror('sort() requires an array')
|
||||
// println(rec_sym.kind)
|
||||
verror('.sort() is an array method')
|
||||
}
|
||||
info := return_sym.info as table.Array
|
||||
info := rec_sym.info as table.Array
|
||||
// No arguments means we are sorting an array of builtins (e.g. `numbers.sort()`)
|
||||
// The type for the comparison fns is the type of the element itself.
|
||||
mut typ := info.elem_type
|
||||
|
Loading…
Reference in New Issue
Block a user