-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Forward reference error includes line numbers #22534
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
+135
−37
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| -- [E039] Reference Error: tests/neg/i14401.scala:6:17 ----------------------------------------------------------------- | ||
| 6 | def f: Int = x; // error | ||
| | ^ | ||
| | x is a forward reference extending over the definition of x (on L7) | ||
| | | ||
| | longer explanation available when compiling with `-explain` | ||
| -- [E039] Reference Error: tests/neg/i14401.scala:10:17 ---------------------------------------------------------------- | ||
| 10 | def f: Int = g; // error | ||
| | ^ | ||
| | g (defined on L12) is a forward reference extending over the definition of x (on L11) | ||
| | | ||
| | longer explanation available when compiling with `-explain` | ||
| -- [E039] Reference Error: tests/neg/i14401.scala:15:17 ---------------------------------------------------------------- | ||
| 15 | def f: Int = g; // error | ||
| | ^ | ||
| | g (defined on L17) is a forward reference extending over the definition of x (on L16) | ||
| | | ||
| | longer explanation available when compiling with `-explain` | ||
| -- [E039] Reference Error: tests/neg/i14401.scala:31:20 ---------------------------------------------------------------- | ||
| 31 | } yield a + 27 // error | ||
| | ^ | ||
| | ec (defined on L33) is a forward reference extending over the definition of z (on L29) | ||
| | | ||
| | longer explanation available when compiling with `-explain` | ||
| -- [E039] Reference Error: tests/neg/i14401.scala:41:28 ---------------------------------------------------------------- | ||
| 41 | class NotUsed {val xs = args} // error | ||
| | ^^^^ | ||
| | args (defined on L44) is a forward reference extending over the definition of dummy (on L42) | ||
| | | ||
| | longer explanation available when compiling with `-explain` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| object Test { | ||
| def f: Int = x; | ||
| val x: Int = f; | ||
|
|
||
| { | ||
| def f: Int = x; // error | ||
| val x: Int = f; | ||
| } | ||
| { | ||
| def f: Int = g; // error | ||
| val x: Int = f; | ||
| def g: Int = x; | ||
| } | ||
| { | ||
| def f: Int = g; // error | ||
| var x: Int = f; | ||
| def g: Int = x; | ||
| } | ||
| { | ||
| def f: Int = g; | ||
| Console.println("foo"); | ||
| def g: Int = f; | ||
| } | ||
| { | ||
| import scala.concurrent.{ExecutionContext, Future}, ExecutionContext.Implicits | ||
|
|
||
| def foo: Future[Int] = { | ||
| val fInt = Future.successful(42) | ||
| val z = for { | ||
| a <- fInt | ||
| } yield a + 27 // error | ||
|
|
||
| implicit val ec: ExecutionContext = Implicits.global | ||
| z | ||
| } | ||
| foo | ||
| } | ||
| } | ||
| object MyApp { | ||
| def main(args: Array[String]) = { | ||
| class NotUsed {val xs = args} // error | ||
| val dummy = false | ||
| // oops, shadows the parameter | ||
| def args = Seq("a","b","c") | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Have you considered spelling out "line X" rather than the shortcut "LX"? Perhaps it's little less cognitive power required while trying to understand the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was probably influenced by github's
library/src/scala/App.scala#L13and in the heat of the moment I wanted to make the "extra" info as brief as possible. The wordlineis a Java indent. The message is already verbose, so(on line 11)is unnoticed at the end of the line, but at the beginning, it pushes the "semantic text" to one's peripheral vision.But repeating the name is usually redundant. The message could read:
I'll try that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a vast improvement at little cost. English gerund is an indent.
Do you think it should say:
just kidding.