Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop mutation of
#to_i
to implicit self
The mutations of all calls to `#to_i` include one that mutates the call into a call to `Integer`. This is a great mutation in all calses where there is an explicit receiver for the `#to_i` call. However, the way that the implicit call to `self.to_i` is parsed results in a receiver of `nil` instead of `self`. As such, we want to limit this particular mutation to calls to `#to_i` that have an explicit receiver. This feels like the correct behavior because the result of the mutation would be (if it parsed): `Integer(nil)`, which doesn't retain the intended behavior of the original source. Another way to approach this would be to mutate the code to `Integer(self)`, but that doesn't feel as correct to me because if you're using the implicit `self` with a call to `#to_i`, you likely are not implementing the strict `#to_int` method as well, which `Integer` relies on. This fix feels like the right mix of correctness and minimal invasiveness. Closes mbj#738
- Loading branch information