-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #1846: add regression test #3810
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
10 commits
Select commit
Hold shift + click to select a range
18d0361
Fix #1846: add regression test
liufengyun 96afef1
add more tests
liufengyun 47256d2
Add Eq check for Apply tree in adapting patterns
liufengyun cff4826
Fix #3812: Refine tests for pattern match
allanrenucci 2734958
fix retyper in checking Select in patterns
liufengyun 0677c77
remove block syntax in patterns
liufengyun 2fe7940
check qualifier is stable in pattern select
liufengyun 798b0d3
remove noise in test code
liufengyun 77ac75c
revert the change to typer
liufengyun 4630203
address review: move check to typer
liufengyun 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
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,21 @@ | ||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val x = 42 | ||
val Y = "42" | ||
|
||
x match { case { 42 } => () } // error | ||
x match { case { 42.toString } => () } // error | ||
x match { case { 42 }.toString => () } // error | ||
x match { case "42".toInt => () } // error | ||
x match { case { "42".toInt } => () } // error | ||
x match { case { "42" }.toInt => () } // error | ||
x match { case { "42".toInt } => () } // error | ||
x match { case Y => () } // error | ||
x match { case Y.toInt => () } // ok | ||
x match { case { Y.toInt } => () } // error | ||
x match { case { Y }.toInt => () } // error | ||
x match { case Y.toString => () } // error | ||
x match { case { Y }.toString => () } // error | ||
x match { case { Y.toString } => () } // error | ||
} | ||
} |
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,14 @@ | ||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val x = 42 | ||
val Y = "42" | ||
|
||
x match { case { 42 } => () } // error | ||
x match { case { "42".toInt } => () } // error | ||
x match { case { "42" }.toInt => () } // error | ||
x match { case { "42".toInt } => () } // error | ||
x match { case { Y.toInt } => () } // error | ||
x match { case { Y }.toInt => () } // error | ||
x match { case Y.toInt => () } // ok | ||
} | ||
} |
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,8 @@ | ||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val x = 42 | ||
val Y = "42" | ||
|
||
x match { case Y.toInt => () } // ok | ||
} | ||
} |
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.
This is an error in scalac, I don't think we should support it either
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.
Good point, a check for stable prefix is missing for patterns here.
Uh oh!
There was an error while loading. Please reload this page.
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.
Now I'm a little unsure about Scalac behavior, as it also rejects the following code:
It seems to me it can be accepted without any issue.
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.
According to scala spec 2.13, the scalac behavior is correct.
https://www.scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#stable-identifier-patterns