1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: handle map.clone()

This commit is contained in:
Alexander Medvednikov 2020-05-26 02:09:26 +02:00
parent 8ea0c812a2
commit b4d88ee4af

View File

@ -731,6 +731,10 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
// call_expr.return_type = call_expr.receiver_type
}
return call_expr.return_type
} else if left_type_sym.kind == .map && method_name == 'clone' {
call_expr.return_type = left_type
call_expr.receiver_type = left_type.to_ptr()
return call_expr.return_type
} else if left_type_sym.kind == .array && method_name in ['first', 'last'] {
info := left_type_sym.info as table.Array
call_expr.return_type = info.elem_type