New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compilation error for ^= operator #10077
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10077?orig=1
|
@som-snytt said: scala> arr1(4) = (arr1(4) ^ arr2(5)).toByte
scala> arr1.update(4, (arr1(4) ^ arr2(5)).toByte)
scala> implicit class cv(val as: Array[Byte]) extends AnyVal {
| def update(i: Int, v: Int): Unit = as.update(i, v.toByte)
| }
defined class cv
scala> arr1(4) ^= arr2(5) Maybe it's possible to spec it in such a way that the conversions are inserted. Anyway, the proposed fix for #9834 is slightly obscurantistical: scala> arr1(4) ^= arr2(5)
<console>:14: error: value ^= is not a member of Byte
Expression does not convert to assignment because:
type mismatch;
found : Int
required: Byte
arr1(4) ^= arr2(5)
^ |
@SethTisue said: scala> var b1 = 0.toByte; b1 ^= b1
<console>:13: error: type mismatch;
found : Int
required: Byte
b1 ^= b1
^ equivalent Java code compiles and the bytecode includes the necessary |
@SethTisue said: |
@som-snytt said:
It would be nice to highlight the error in the expansion without adding a caret line. |
Closing as duplicate of the linked ticket by which the error message was improved. |
Expected: successful compilation
Actual:
The text was updated successfully, but these errors were encountered: