aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorliu fengyun <liufengyunchina@gmail.com>2016-03-18 14:38:06 +0100
committerliu fengyun <liufengyunchina@gmail.com>2016-03-18 19:56:53 +0100
commit7e7058a22fcf8806e718bbba94080935a44ece0c (patch)
tree47416632c035a7743415b1047009642f17acecaa /src
parentf8ebf777b92e858a7ff8cfdf022e151b4f056920 (diff)
downloaddotty-7e7058a22fcf8806e718bbba94080935a44ece0c.tar.gz
dotty-7e7058a22fcf8806e718bbba94080935a44ece0c.tar.bz2
dotty-7e7058a22fcf8806e718bbba94080935a44ece0c.zip
better positioning of `_*` not last argument error
The error should be at the beginning of the underscore `_`, not the next token after the star `*`, which is the default.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/parsing/JavaParsers.scala2
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/parsing/JavaParsers.scala b/src/dotty/tools/dotc/parsing/JavaParsers.scala
index b4d01a0da..fbb362354 100644
--- a/src/dotty/tools/dotc/parsing/JavaParsers.scala
+++ b/src/dotty/tools/dotc/parsing/JavaParsers.scala
@@ -175,6 +175,8 @@ object JavaParsers {
/** Consume one token of the specified type, or
* signal an error if it is not there.
+ *
+ * @return The offset at the start of the token to accept
*/
def accept(token: Int): Int = {
val offset = in.offset
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index 6ec75a8b2..5178f645b 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -227,6 +227,8 @@ object Parsers {
/** Consume one token of the specified type, or
* signal an error if it is not there.
+ *
+ * @return The offset at the start of the token to accept
*/
def accept(token: Int): Int = {
val offset = in.offset
@@ -234,7 +236,7 @@ object Parsers {
syntaxErrorOrIncomplete(expectedMsg(token))
}
if (in.token == token) in.nextToken()
- in.offset
+ offset
}
/** semi = nl {nl} | `;'
@@ -1011,7 +1013,7 @@ object Parsers {
val uscoreStart = in.skipToken()
if (isIdent(nme.raw.STAR)) {
in.nextToken()
- if (in.token != RPAREN) syntaxError("`_*' can be used only for last argument")
+ if (in.token != RPAREN) syntaxError("`_*' can be used only for last argument", uscoreStart)
Typed(t, atPos(uscoreStart) { Ident(tpnme.WILDCARD_STAR) })
} else {
syntaxErrorOrIncomplete("`*' expected"); t