-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Reword error messages in initialization checker to be more user friendly. #17030
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
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
da1b028
Reword error messages to be more user friendly.
q-ata 585409a
Update check files, minor wording changes to error messages
q-ata 4cc629e
Reword the stringified versions of some objects
q-ata 6f22980
Add parentheses to make warnings more clear
q-ata 36298a2
Address feedback.
q-ata 603822e
Make warning message more accurate.
q-ata 8af1b29
Reformat the output when printing a function to console in init checker
q-ata 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
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
-- Error: tests/init/neg/closureLeak.scala:11:14 ----------------------------------------------------------------------- | ||
11 | l.foreach(a => a.addX(this)) // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = Fun { this = ThisRef[class Outer], owner = class Outer }. Calling trace: | ||
| -> class Outer { [ closureLeak.scala:1 ] | ||
| ^ | ||
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^ | ||
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function where "this" is (the original object of type (class Outer) where initialization checking started) and the function owner is an object of type (class Outer). Only transitively initialized arguments may be passed to methods (except constructors). Calling trace: | ||
|-> class Outer { [ closureLeak.scala:1 ] | ||
| ^ | ||
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
| Promoting the value to hot (transitively initialized) failed due to the following problem: | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class Outer]. | ||
| Non initialized field(s): value p. Promotion trace: | ||
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^ | ||
|Promoting the value to transitively initialized (Hot) failed due to the following problem: | ||
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class Outer) where initialization checking started. Only transitively initialized arguments may be passed to methods (except constructors). | ||
|Non initialized field(s): value p. Promotion trace: | ||
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^ |
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------ | ||
9 | compare() // error | ||
| ^^^^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class B]. | ||
| Non initialized field(s): value result. Calling trace: | ||
| -> class B extends A { [ default-this.scala:6 ] | ||
| ^ | ||
| -> val result = updateThenCompare(5) [ default-this.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| -> def updateThenCompare(c: Int): Boolean = { [ default-this.scala:7 ] | ||
| ^ | ||
| -> compare() // error [ default-this.scala:9 ] | ||
| ^^^^^^^ | ||
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class B) where initialization checking started. Only transitively initialized arguments may be passed to methods (except constructors). | ||
|Non initialized field(s): value result. Calling trace: | ||
|-> class B extends A { [ default-this.scala:6 ] | ||
| ^ | ||
|-> val result = updateThenCompare(5) [ default-this.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|-> def updateThenCompare(c: Int): Boolean = { [ default-this.scala:7 ] | ||
| ^ | ||
|-> compare() // error [ default-this.scala:9 ] | ||
| ^^^^^^^ |
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
-- Error: tests/init/neg/i15459.scala:3:10 ----------------------------------------------------------------------------- | ||
3 | println(this) // error | ||
| ^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class Sub]. | ||
| Non initialized field(s): value b. Calling trace: | ||
| -> class Sub extends Sup: [ i15459.scala:5 ] | ||
| ^ | ||
| -> class Sup: [ i15459.scala:1 ] | ||
| ^ | ||
| -> println(this) // error [ i15459.scala:3 ] | ||
| ^^^^ | ||
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class Sub) where initialization checking started. Only transitively initialized arguments may be passed to methods (except constructors). | ||
|Non initialized field(s): value b. Calling trace: | ||
|-> class Sub extends Sup: [ i15459.scala:5 ] | ||
| ^ | ||
|-> class Sup: [ i15459.scala:1 ] | ||
| ^ | ||
|-> println(this) // error [ i15459.scala:3 ] | ||
| ^^^^ |
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
-- Error: tests/init/neg/inherit-non-hot.scala:6:32 -------------------------------------------------------------------- | ||
6 | if b == null then b = new B(this) // error | ||
| ^^^^^^^^^^^^^^^ | ||
| The RHS of reassignment must be hot. Found = Warm[class B] { outer = Hot, args = (Cold) }. Calling trace: | ||
| -> class C extends A { [ inherit-non-hot.scala:15 ] | ||
| ^ | ||
| -> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ] | ||
| ^^^ | ||
| -> def toB: B = [ inherit-non-hot.scala:5 ] | ||
| ^ | ||
| -> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ] | ||
| ^^^^^^^^^^^^^^^ | ||
|The RHS of reassignment must be transitively initialized (Hot). It was found to be a non-transitively initialized (Warm) object of type (class B) { outer = a transitively initialized (Hot) object, args = (an uninitialized (Cold) object) }. Calling trace: | ||
|-> class C extends A { [ inherit-non-hot.scala:15 ] | ||
| ^ | ||
|-> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ] | ||
| ^^^ | ||
|-> def toB: B = [ inherit-non-hot.scala:5 ] | ||
| ^ | ||
|-> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ] | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
| Promoting the value to hot (transitively initialized) failed due to the following problem: | ||
| Cannot prove that the field value a is hot. Found = Cold. Promotion trace: | ||
| -> class B(a: A) { [ inherit-non-hot.scala:10 ] | ||
| ^^^^ | ||
|Promoting the value to transitively initialized (Hot) failed due to the following problem: | ||
|Could not verify that the field value a is transitively initialized (Hot). It was found to be an uninitialized (Cold) object. Promotion trace: | ||
|-> class B(a: A) { [ inherit-non-hot.scala:10 ] | ||
| ^^^^ |
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
-- Error: tests/init/neg/inlined-method.scala:8:45 --------------------------------------------------------------------- | ||
8 | scala.runtime.Scala3RunTime.assertFailed(message) // error | ||
| ^^^^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class InlineError]. | ||
| Non initialized field(s): value v. Calling trace: | ||
| -> class InlineError { [ inlined-method.scala:1 ] | ||
| ^ | ||
| -> Assertion.failAssert(this) [ inlined-method.scala:2 ] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| -> scala.runtime.Scala3RunTime.assertFailed(message) // error [ inlined-method.scala:8 ] | ||
| ^^^^^^^ | ||
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class InlineError) where initialization checking started. Only transitively initialized arguments may be passed to methods (except constructors). | ||
|Non initialized field(s): value v. Calling trace: | ||
|-> class InlineError { [ inlined-method.scala:1 ] | ||
| ^ | ||
|-> Assertion.failAssert(this) [ inlined-method.scala:2 ] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|-> scala.runtime.Scala3RunTime.assertFailed(message) // error [ inlined-method.scala:8 ] | ||
| ^^^^^^^ |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
-- Error: tests/init/neg/inner-first.scala:3:12 ------------------------------------------------------------------------ | ||
3 | println(this) // error | ||
| ^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class B]. | ||
| Non initialized field(s): value n. Calling trace: | ||
| -> class B: [ inner-first.scala:2 ] | ||
| ^ | ||
| -> println(this) // error [ inner-first.scala:3 ] | ||
| ^^^^ | ||
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class B) where initialization checking started. Only transitively initialized arguments may be passed to methods (except constructors). | ||
|Non initialized field(s): value n. Calling trace: | ||
|-> class B: [ inner-first.scala:2 ] | ||
| ^ | ||
|-> println(this) // error [ inner-first.scala:3 ] | ||
| ^^^^ |
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.
Uh oh!
There was an error while loading. Please reload this page.