Automatically clone value types when passed as references to owned arguments
Inko treats e.g. Int
as not being compatible with ref Int
or mut Int
. On paper that makes sense, but in practise it leads to a lot of clone()
calls just to get an owned value. In addition, methods that take e.g. an Int
now have to decide if they want to take a ref Int
(or mut Int
), or an Int
.
To solve this issue we should extend the compiler such that when you pass a ref T
/mut T
to a T
, where T
is a value type, the compiler instead passes a clone of the value type.