checker: handle map.clone()

pull/5049/head
Alexander Medvednikov 2020-05-26 02:09:26 +02:00
parent 8ea0c812a2
commit b4d88ee4af
1 changed files with 4 additions and 0 deletions

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 // call_expr.return_type = call_expr.receiver_type
} }
return call_expr.return_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'] { } else if left_type_sym.kind == .array && method_name in ['first', 'last'] {
info := left_type_sym.info as table.Array info := left_type_sym.info as table.Array
call_expr.return_type = info.elem_type call_expr.return_type = info.elem_type