8000 Merge pull request #11056 from som-snytt/issue/caret-on-bad-patvar · scala/scala@6d0b134 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d0b134

Browse files
authored
Merge pull request #11056 from som-snytt/issue/caret-on-bad-patvar
Adjust caret in error message
2 parents b01ac03 + 5d2e19b commit 6d0b134

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,13 +2197,10 @@ self =>
21972197
*/
21982198
def pattern1(): Tree = pattern2() match {
21992199
case p @ Ident(name) if in.token == COLON =>
2200-
if (nme.isVariableName(name)) {
2201-
p.removeAttachment[BackquotedIdentifierAttachment.type]
2202-
atPos(p.pos.start, in.skipToken())(Typed(p, compoundType()))
2203-
} else {
2204-
syntaxError(in.offset, "Pattern variables must start with a lower-case letter. (SLS 8.1.1.)")
2205-
p
2206-
}
2200+
if (!nme.isVariableName(name))
2201+
syntaxError(p.pos.point, "Pattern variables must start with a lower-case letter. (SLS 8.1.1.)")
2202+
p.removeAttachment[BackquotedIdentifierAttachment.type]
2203+
atPos(p.pos.start, in.skipToken())(Typed(p, compoundType()))
22072204
case p => p
22082205
}
22092206

test/files/neg/t5357.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
t5357.scala:5: error: Pattern variables must start with a lower-case letter. (SLS 8.1.1.)
22
case A: N => 1
3-
^
3+
^
44
1 error

test/files/neg/t8044-b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
t8044-b.scala:3: error: Pattern variables must start with a lower-case letter. (SLS 8.1.1.)
22
def g = 42 match { case `Oops` : Int => } // must be varish
3-
^
3+
^
44
1 error

0 commit comments

Comments
 (0)
0