Skip to content

Commit 552a56a

Browse files
committed
Merge pull request #1184 from liufengyun/error-pos
better positioning of `_*` not last argument error
2 parents fadcf44 + 7e7058a commit 552a56a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ object JavaParsers {
175175

176176
/** Consume one token of the specified type, or
177177
* signal an error if it is not there.
178+
*
179+
* @return The offset at the start of the token to accept
178180
*/
179181
def accept(token: Int): Int = {
180182
val offset = in.offset

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,16 @@ object Parsers {
227227

228228
/** Consume one token of the specified type, or
229229
* signal an error if it is not there.
230+
*
231+
* @return The offset at the start of the token to accept
230232
*/
231233
def accept(token: Int): Int = {
232234
val offset = in.offset
233235
if (in.token != token) {
234236
syntaxErrorOrIncomplete(expectedMsg(token))
235237
}
236238
if (in.token == token) in.nextToken()
237-
in.offset
239+
offset
238240
}
239241

240242
/** semi = nl {nl} | `;'
@@ -1019,7 +1021,7 @@ object Parsers {
10191021
val uscoreStart = in.skipToken()
10201022
if (isIdent(nme.raw.STAR)) {
10211023
in.nextToken()
1022-
if (in.token != RPAREN) syntaxError("`_*' can be used only for last argument")
1024+
if (in.token != RPAREN) syntaxError("`_*' can be used only for last argument", uscoreStart)
10231025
Typed(t, atPos(uscoreStart) { Ident(tpnme.WILDCARD_STAR) })
10241026
} else {
10251027
syntaxErrorOrIncomplete("`*' expected"); t

0 commit comments

Comments
 (0)