aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorAndrew Zurn <awzurn@gmail.com>2016-10-25 10:57:07 -0700
committerAndrew Zurn <awzurn@gmail.com>2016-10-25 13:14:39 -0700
commitfc3c6a6609a6ca4682c1b72da0e8f6e8feec630f (patch)
treedfc16b30b93e88b142a1ca37e36be65b71939fb4 /src/dotty/tools/dotc
parentf57086d07f0f748830ff8506e7719e339873283d (diff)
downloaddotty-fc3c6a6609a6ca4682c1b72da0e8f6e8feec630f.tar.gz
dotty-fc3c6a6609a6ca4682c1b72da0e8f6e8feec630f.tar.bz2
dotty-fc3c6a6609a6ca4682c1b72da0e8f6e8feec630f.zip
Add error message - Parsers.scala:695
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala2
-rw-r--r--src/dotty/tools/dotc/reporting/diagnostic/messages.scala24
2 files changed, 25 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index 8fc99f072..6871916dd 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -692,7 +692,7 @@ object Parsers {
else {
for (t <- ts)
if (t.isInstanceOf[ByNameTypeTree])
- syntaxError("no by-name parameter type allowed here", t.pos)
+ syntaxError(ByNameParameterNotSupported())
val tuple = atPos(start) { makeTupleOrParens(ts) }
infixTypeRest(refinedTypeRest(withTypeRest(simpleTypeRest(tuple))))
}
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index b0ce5b132..f76512bc7 100644
--- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -581,4 +581,28 @@ object messages {
}
}
+
+ case class ByNameParameterNotSupported()(implicit ctx: Context) extends Message(21) {
+ val kind = "Syntax"
+
+ val msg = "By-name parameter type not allowed here."
+
+ val explanation =
+ hl"""|By-name parameters act like functions that are only evaluated when referenced,
+ |allowing for lazy evaluation of a parameter.
+ |
+ |An example of using a by-name parameter would look like:
+ |${"def func(f: => Boolean) = f // 'f' is evaluated when referenced within the function"}
+ |
+ |An example of the syntax of passing an actual function as a parameter:
+ |${"def func(f: (Boolean => Boolean)) = f(true)"}
+ |
+ |or:
+ |
+ |${"def func(f: Boolean => Boolean) = f(true)"}
+ |
+ |And the usage could be as such:
+ |${"func(bool => // do something...)"}
+ |""".stripMargin
+ }
}