mutagen icon indicating copy to clipboard operation
mutagen copied to clipboard

Mutation: Swap similar operators

Open hmvp opened this issue 7 years ago • 2 comments

One option would to swap + and - or * and %.

Also similar for x += 1 and x -=1 etc

However this will probably trigger under/overflow issues.

hmvp avatar Feb 18 '18 10:02 hmvp

Under-/overflow issues are the least of my worries: There may be types that implement AddAssign, but not SubAssign (for example String) and the other traits are the same.

We may be able to do this by rebuilding most of typeck, but I think this is an advanced feature...

llogiq avatar Feb 18 '18 11:02 llogiq

This can be done with specialization so we let typeck infer the correct code for us.

llogiq avatar Mar 08 '18 23:03 llogiq