Skip to content

Commit c49ff71

Browse files
nox213som-snytt
authored andcommitted
patvar: adjust caret in error message
1 parent 5bbd005 commit c49ff71

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3188,7 +3188,7 @@ object Parsers {
31883188
| * variable pattern, e.g. `case x: String =>`
31893189
| * number literal pattern, e.g. `case 10.5: Double =>`
31903190
|are no longer supported. Remove the type ascription or move it to a separate variable pattern.""",
3191-
in.sourcePos(),
3191+
p.sourcePos,
31923192
MigrationVersion.AscriptionAfterPattern)
31933193
in.nextToken()
31943194
ascription(p, location)

tests/neg/i15784.check

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
| Not found: A
1111
|
1212
| longer explanation available when compiling with `-explain`
13-
-- Warning: tests/neg/i15784.scala:7:8 ---------------------------------------------------------------------------------
13+
-- Warning: tests/neg/i15784.scala:7:7 ---------------------------------------------------------------------------------
1414
7 | case X: Int => X // warn
15-
| ^
16-
| Type ascriptions after patterns other than:
17-
| * variable pattern, e.g. `case x: String =>`
18-
| * number literal pattern, e.g. `case 10.5: Double =>`
19-
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
20-
-- Warning: tests/neg/i15784.scala:10:12 -------------------------------------------------------------------------------
15+
| ^
16+
| Type ascriptions after patterns other than:
17+
| * variable pattern, e.g. `case x: String =>`
18+
| * number literal pattern, e.g. `case 10.5: Double =>`
19+
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
20+
-- Warning: tests/neg/i15784.scala:10:7 --------------------------------------------------------------------------------
2121
10 | case `Int`: Int => `Int` // warn
22-
| ^
23-
| Type ascriptions after patterns other than:
24-
| * variable pattern, e.g. `case x: String =>`
25-
| * number literal pattern, e.g. `case 10.5: Double =>`
26-
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
22+
| ^^^^^
23+
| Type ascriptions after patterns other than:
24+
| * variable pattern, e.g. `case x: String =>`
25+
| * number literal pattern, e.g. `case 10.5: Double =>`
26+
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.

tests/neg/t5702-neg-bad-and-wild.check

-7
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@
5454
| no pattern match extractor named * was found
5555
|
5656
| longer explanation available when compiling with `-explain`
57-
-- Warning: tests/neg/t5702-neg-bad-and-wild.scala:13:22 ---------------------------------------------------------------
58-
13 | case List(1, _*3:) => // error // error
59-
| ^
60-
| Type ascriptions after patterns other than:
61-
| * variable pattern, e.g. `case x: String =>`
62-
| * number literal pattern, e.g. `case 10.5: Double =>`
63-
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
6457
-- Warning: tests/neg/t5702-neg-bad-and-wild.scala:22:20 ---------------------------------------------------------------
6558
22 | val K(x @ _*) = k
6659
| ^

0 commit comments

Comments
 (0)