It seems correct from the func perspective, so it passes the compilation. But the question is what the user is expected to get?
String and Address
get fun test_string(): String {
let a: String = "foo";
a %= "bar";
return a;
}
The func compilation fails:
💼 Compiling project sample...
> SampleTactContract: tact compiler
> SampleTactContract: func compiler
Func compilation error: output/sample_SampleTactContract.code.fc:30:20: error: cannot apply function _%_ : (int, int) -> int to arguments of type (slice, slice): cannot unify type slice with int
$a1 = $a1 % $a2;
💥 Compilation failed. Skipping packaging
More complex types
The FunC compilation fails, as we are trying to apply an arithmetic operation to a non-numeric type.
Therefore, it is suggested to restrict these augmented assignment operations for all non-numeric types. If we are going to add boolean operations later, we should consider this in the typechecking as well.
Augmented assignments could be used with the following operations:
"+" | "-" | "*" | "/" | "%"
.It seems reasonable that these operations should be applied to numeric types, but this is not always the case.
Consider their behavior on different types:
Generates the following FunC code:
It seems correct from the func perspective, so it passes the compilation. But the question is what the user is expected to get?
The func compilation fails:
Therefore, it is suggested to restrict these augmented assignment operations for all non-numeric types. If we are going to add boolean operations later, we should consider this in the typechecking as well.