-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix init error in test #8109
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
Fix init error in test #8109
Conversation
@@ -25,12 +25,12 @@ object TypeLevel { | |||
def mirror(ordinal: Int): Mirror = | |||
mirror(ordinal, EmptyProduct) | |||
|
|||
val label: Array[Array[String]] = | |||
initLabels(0, 0, new mutable.ArrayBuffer[String], new mutable.ArrayBuffer[Array[String]]) | |||
|
|||
private final val elemSeparator = '\000' | |||
private final val caseSeparator = '\001' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liufengyun what happens if it is an inline val
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, due to const-fold it's not an error. The checker now runs before const-fold, it thus reports an error.
But I think it's still good to report errors here, as in this case const-fold changes the semantics of programs, which is too subtle for end users.
Note: due to const-fold, the code does not misbehave at runtime. However, it's still good to report errors here, as in this case const-fold changes the semantics of programs, which is too subtle for end users. The field `elemSeparator` and `caseSeparator` are used before they are initialized. -- Error: tests/run/typeclass-derivation2a.scala:31:22 ------------------------- 31 | private final val elemSeparator = '\000' | ^ |Access non-initialized field value elemSeparator. Calling trace: | -> initLabels(0, 0, new mutable.ArrayBuffer[String], new mutable.ArrayBuffer[Array[String]]) [ typeclass-derivation2a.scala:29 ] | -> else if (labelsStr(cur) == elemSeparator) [ typeclass-derivation2a.scala:43 ] -- Error: tests/run/typeclass-derivation2a.scala:32:22 ------------------------- 32 | private final val caseSeparator = '\001' | ^ |Access non-initialized field value caseSeparator. Calling trace: | -> initLabels(0, 0, new mutable.ArrayBuffer[String], new mutable.ArrayBuffer[Array[String]]) [ typeclass-derivation2a.scala:29 ] | -> else if (labelsStr(cur) == caseSeparator) [ typeclass-derivation2a.scala:41 ] 2 errors found
```Scala -- Error: tests/run/tuples1.scala:28:27 ---------------------------------------- 28 | val c0_1 = x0 ++ x1; val c0_1c: Int *: Unit = c0_1c; println(s"c0_1 = $c0_1") | ^ |Access non-initialized field value c0_1c. Calling trace: | -> val c0_1 = x0 ++ x1; val c0_1c: Int *: Unit = c0_1c; println(s"c0_1 = $c0_1") [ tuples1.scala:28 ] -- Error: tests/run/tuples1.scala:29:27 ---------------------------------------- 29 | val c1_0 = x1 ++ x0; val c1_0c: Int *: Unit = c1_0c; println(s"c1_0 = $c1_0") | ^ |Access non-initialized field value c1_0c. Calling trace: | -> val c1_0 = x1 ++ x0; val c1_0c: Int *: Unit = c1_0c; println(s"c1_0 = $c1_0") [ tuples1.scala:29 ] ```
The field
elemSeparator
andcaseSeparator
are used before they are initialized.