I was writing some scala 3 code where I wanted something like:
val one = 1 | 2 = 1 val two = 2 | 3 = one + 1
but this does not compile.
on the other hand:
val one: 1 = 1 val two: 2 = one + 1
does compile. So, it seem that the compiler understands that if you add 1 to a value of type 1, you get one of type 2, but it can’t distribute that across a union of all integer values. It seems tractable to me where you have a union of primitives of the same type that you could distribute operations with singleton types across those unions.
Are there any issues that I am missing to adding support in the compiler for these kinds of operations on primitive values? It could be rather useful, I think.