Skip to content

Commit d60f89d

Browse files
authored
Merge pull request #1699 from Blaisorblade/clarify-error
Clarify error for unbound identifiers and add/fix a few comments
2 parents 28c2e04 + e11c91a commit d60f89d

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ object Parsers {
151151
/* ------------- ERROR HANDLING ------------------------------------------- */
152152

153153
/** The offset of the last time when a statement on a new line was definitely
154-
* encountered in the current scope or an outer scope\
154+
* encountered in the current scope or an outer scope.
155155
*/
156156
private var lastStatOffset = -1
157157

@@ -505,7 +505,7 @@ object Parsers {
505505
if (t1 ne t) t1 else dotSelectors(selector(t), finish)
506506
}
507507

508-
/** Dotelectors ::= { `.' ident()
508+
/** DotSelectors ::= { `.' ident()
509509
*
510510
* Accept `.' separated identifiers acting as a selectors on given tree `t`.
511511
* @param finish An alternative parse in case the token following a `.' is not an identifier.
@@ -521,7 +521,7 @@ object Parsers {
521521
* | [Ident `.'] this
522522
*
523523
* @param thisOK If true, [Ident `.'] this is acceptable as the path.
524-
* If false, another selection is required aftre the `this`.
524+
* If false, another selection is required after the `this`.
525525
* @param finish An alternative parse in case the token following a `.' is not an identifier.
526526
* If the alternative does not apply, its tree argument is returned unchanged.
527527
*/

src/dotty/tools/dotc/reporting/diagnostic/Message.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ object Message {
1818
/** A `Message` contains all semantic information necessary to easily
1919
* comprehend what caused the message to be logged. Each message can be turned
2020
* into a `MessageContainer` which contains the log level and can later be
21-
* consumed by a subclass of `Reporter`.
21+
* consumed by a subclass of `Reporter`. However, the error position is only
22+
* part of `MessageContainer`, not `Message`.
2223
*
2324
* @param errorId a unique number identifying the message, this will later be
2425
* used to reference documentation online
@@ -31,7 +32,7 @@ abstract class Message(val errorId: Int) { self =>
3132
* > expected: String
3233
* > found: Int
3334
*
34-
* This message wil be placed underneath the position given by the enclosing
35+
* This message will be placed underneath the position given by the enclosing
3536
* `MessageContainer`
3637
*/
3738
def msg: String

src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ object messages {
184184

185185
val caseDef = s"case $pat$guard => $body"
186186

187-
hl"""|For each ${"case"} bound variable names have to be unique. In:
187+
hl"""|For each ${"case"} bound variable names have to be unique. In:
188188
|
189189
|$caseDef
190190
|
@@ -194,12 +194,14 @@ object messages {
194194

195195
case class MissingIdent(tree: untpd.Ident, treeKind: String, name: String)(implicit ctx: Context)
196196
extends Message(6) {
197-
val kind = "Missing Identifier"
197+
val kind = "Unbound Identifier"
198198
val msg = em"not found: $treeKind$name"
199199

200200
val explanation = {
201-
hl"""|An identifier for `$treeKind$name` is missing. This means that something
202-
|has either been misspelt or you're forgetting an import"""
201+
hl"""|The identifier for `$treeKind$name` is not bound, that is,
202+
|no declaration for this identifier can be found.
203+
|That can happen for instance if $name or its declaration has either been
204+
|misspelt, or if you're forgetting an import"""
203205
}
204206
}
205207

0 commit comments

Comments
 (0)