bug icon indicating copy to clipboard operation
bug copied to clipboard

REPL doesn't report op= mutations

Open som-snytt opened this issue 2 years ago • 1 comments

Reproduction steps

Scala version: 2.13

scala 2.13.12> var x = 42
var x: Int = 42

scala 2.13.12> x = 17
// mutated x

scala 2.13.12> x += 10

scala 2.13.12> x
val res1: Int = 27

Problem

It should say that x was mutated by assignment +=.

som-snytt avatar Oct 17 '23 20:10 som-snytt

This would be a good little starter project for somebody, either in Scala 2 or Scala 3 or both.

In Scala 3 (3.4.0-RC3), instead of "mutated x" it actually shows the new value, which seems like a better design:

scala> var x = 42
var x: Int = 42
                                                                                                    
scala> x = 20
x: Int = 20

But Scala 3 also fails to handle += and friends the same way it handles plain assignment

scala> x += 10
                                                                                                    
scala> 

SethTisue avatar Jan 26 '24 23:01 SethTisue