Skip to content

Clarify error for unbound identifiers and add/fix a few comments #1699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ object Parsers {
/* ------------- ERROR HANDLING ------------------------------------------- */

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

Expand Down Expand Up @@ -505,7 +505,7 @@ object Parsers {
if (t1 ne t) t1 else dotSelectors(selector(t), finish)
}

/** Dotelectors ::= { `.' ident()
/** DotSelectors ::= { `.' ident()
*
* Accept `.' separated identifiers acting as a selectors on given tree `t`.
* @param finish An alternative parse in case the token following a `.' is not an identifier.
Expand All @@ -521,7 +521,7 @@ object Parsers {
* | [Ident `.'] this
*
* @param thisOK If true, [Ident `.'] this is acceptable as the path.
* If false, another selection is required aftre the `this`.
* If false, another selection is required after the `this`.
* @param finish An alternative parse in case the token following a `.' is not an identifier.
* If the alternative does not apply, its tree argument is returned unchanged.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/dotty/tools/dotc/reporting/diagnostic/Message.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ object Message {
/** A `Message` contains all semantic information necessary to easily
* comprehend what caused the message to be logged. Each message can be turned
* into a `MessageContainer` which contains the log level and can later be
* consumed by a subclass of `Reporter`.
* consumed by a subclass of `Reporter`. However, the error position is only
* part of `MessageContainer`, not `Message`.
*
* @param errorId a unique number identifying the message, this will later be
* used to reference documentation online
Expand All @@ -31,7 +32,7 @@ abstract class Message(val errorId: Int) { self =>
* > expected: String
* > found: Int
*
* This message wil be placed underneath the position given by the enclosing
* This message will be placed underneath the position given by the enclosing
* `MessageContainer`
*/
def msg: String
Expand Down
10 changes: 6 additions & 4 deletions src/dotty/tools/dotc/reporting/diagnostic/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ object messages {

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

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

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

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

Expand Down