Having:
case class A(x: Int) {
def >>= (y: A) = A(x * y.x)
def >> (y: A) = A(x + y.x)
}
Since >>=
and >>
both start with >
, they should have the same precedence and left associativity.
However:
A(5) >>= A(3) >> A(2)
returns 25.
But should return 17, because:
A(5) >>= A(3) >> A(2) == (A(5) >>= A(3)) >> A(2) == 17
It looks like Scala compiler puts parantheses in the wrong place.
Bug?