Skip to content

Commit 5f3547e

Browse files
committed
Underline assignment correctly in error message
1 parent 9bb3108 commit 5f3547e

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,12 +1349,12 @@ object Semantic:
13491349
case Select(qual, _) =>
13501350
eval(qual, thisV, klass)
13511351
val res = eval(rhs, thisV, klass)
1352-
extendTrace(rhs) {
1352+
extendTrace(expr) {
13531353
res.ensureHot("The RHS of reassignment must be fully initialized.")
13541354
}
13551355
case id: Ident =>
13561356
val res = eval(rhs, thisV, klass)
1357-
extendTrace(rhs) {
1357+
extendTrace(expr) {
13581358
res.ensureHot("The RHS of reassignment must be fully initialized.")
13591359
}
13601360

tests/init/neg/inherit-non-hot.check

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
-- Error: tests/init/neg/inherit-non-hot.scala:6:34 --------------------------------------------------------------------
1+
-- Error: tests/init/neg/inherit-non-hot.scala:6:32 --------------------------------------------------------------------
22
6 | if b == null then b = new B(this) // error
3-
| ^^^^^^^^^^^
4-
| The RHS of reassignment must be fully initialized. Calling trace:
5-
| -> class C extends A { [ inherit-non-hot.scala:15 ]
6-
| ^
7-
| -> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ]
8-
| ^^^
9-
| -> def toB: B = [ inherit-non-hot.scala:5 ]
10-
| ^
11-
| -> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ]
12-
| ^^^^^^^^^^^
3+
| ^^^^^^^^^^^^^^^
4+
| The RHS of reassignment must be fully initialized. Calling trace:
5+
| -> class C extends A { [ inherit-non-hot.scala:15 ]
6+
| ^
7+
| -> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ]
8+
| ^^^
9+
| -> def toB: B = [ inherit-non-hot.scala:5 ]
10+
| ^
11+
| -> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ]
12+
| ^^^^^^^^^^^^^^^
1313
|
14-
| Promoting the value to fully initialized failed due to the following problem:
15-
| Cannot prove that the field val a is fully initialized.
14+
| Promoting the value to fully initialized failed due to the following problem:
15+
| Cannot prove that the field val a is fully initialized.

tests/init/neg/local-warm4.check

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
-- Error: tests/init/neg/local-warm4.scala:18:20 -----------------------------------------------------------------------
1+
-- Error: tests/init/neg/local-warm4.scala:18:18 -----------------------------------------------------------------------
22
18 | a = newA // error
3-
| ^^^^
4-
| The RHS of reassignment must be fully initialized. Calling trace:
5-
| -> object localWarm { [ local-warm4.scala:1 ]
6-
| ^
7-
| -> val a = new A(5) [ local-warm4.scala:26 ]
8-
| ^^^^^^^^
9-
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
10-
| ^
11-
| -> val b = new B(y) [ local-warm4.scala:10 ]
12-
| ^^^^^^^^
13-
| -> class B(x: Int) extends A(x) { [ local-warm4.scala:13 ]
14-
| ^
15-
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
16-
| ^
17-
| -> increment() [ local-warm4.scala:9 ]
18-
| ^^^^^^^^^^^
19-
| -> override def increment(): Unit = { [ local-warm4.scala:15 ]
20-
| ^
21-
| -> updateA() [ local-warm4.scala:21 ]
22-
| ^^^^^^^^^
23-
| -> def updateA(): Unit = { [ local-warm4.scala:16 ]
24-
| ^
25-
| -> a = newA // error [ local-warm4.scala:18 ]
26-
| ^^^^
3+
| ^^^^^^^^
4+
| The RHS of reassignment must be fully initialized. Calling trace:
5+
| -> object localWarm { [ local-warm4.scala:1 ]
6+
| ^
7+
| -> val a = new A(5) [ local-warm4.scala:26 ]
8+
| ^^^^^^^^
9+
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
10+
| ^
11+
| -> val b = new B(y) [ local-warm4.scala:10 ]
12+
| ^^^^^^^^
13+
| -> class B(x: Int) extends A(x) { [ local-warm4.scala:13 ]
14+
| ^
15+
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
16+
| ^
17+
| -> increment() [ local-warm4.scala:9 ]
18+
| ^^^^^^^^^^^
19+
| -> override def increment(): Unit = { [ local-warm4.scala:15 ]
20+
| ^
21+
| -> updateA() [ local-warm4.scala:21 ]
22+
| ^^^^^^^^^
23+
| -> def updateA(): Unit = { [ local-warm4.scala:16 ]
24+
| ^
25+
| -> a = newA // error [ local-warm4.scala:18 ]
26+
| ^^^^^^^^

0 commit comments

Comments
 (0)