-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Reject postfix ops already in Parser #14677
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 all commits
Commits
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
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
This file was deleted.
Oops, something went wrong.
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,3 +1,4 @@ | ||
import language.postfixOps | ||
object Test { | ||
foo = macro Impls . foo [ U ] += // error // 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,17 @@ | ||
-- [E018] Syntax Error: tests/neg/i14564.scala:5:28 -------------------------------------------------------------------- | ||
5 |def test = sum"${ List(42)* }" // error // error | ||
| ^ | ||
| expression expected but [31m'}'[0m found | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E008] Not Found Error: tests/neg/i14564.scala:5:26 ----------------------------------------------------------------- | ||
5 |def test = sum"${ List(42)* }" // error // error | ||
| ^^^^^^^^^ | ||
| value * is not a member of List[Int], but could be made available as an extension method. | ||
| | ||
| One of the following imports might make progress towards fixing the problem: | ||
| | ||
| import math.Fractional.Implicits.infixFractionalOps | ||
| import math.Integral.Implicits.infixIntegralOps | ||
| import math.Numeric.Implicits.infixNumericOps | ||
| |
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,6 @@ | ||
import language.postfixOps as _ | ||
|
||
extension (sc: StringContext) def sum(xs: Int*): String = xs.sum.toString | ||
|
||
def test = sum"${ List(42)* }" // error // 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
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,3 +1,4 @@ | ||
import language.postfixOps | ||
object DepBug { | ||
class A { | ||
class B | ||
|
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,16 @@ | ||
-- [E018] Syntax Error: tests/neg/i5498-postfixOps.scala:4:10 ---------------------------------------------------------- | ||
4 | 1 second // error: usage of postfix operator | ||
| ^ | ||
| expression expected but [31mend of statement[0m found | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E018] Syntax Error: tests/neg/i5498-postfixOps.scala:6:37 ---------------------------------------------------------- | ||
6 | Seq(1, 2).filter(List(1,2) contains) // error: usage of postfix operator // error | ||
| ^ | ||
| expression expected but [31m')'[0m found | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- Error: tests/neg/i5498-postfixOps.scala:6:0 ------------------------------------------------------------------------- | ||
6 | Seq(1, 2).filter(List(1,2) contains) // error: usage of postfix operator // error | ||
|^ | ||
|no implicit argument of type scala.concurrent.duration.DurationConversions.Classifier[Null] was found for parameter ev of method second in trait DurationConversions |
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,3 +1,4 @@ | ||
import language.postfixOps | ||
type Tr[+A] | ||
extension [A, B](tr: Tr[A]) inline def map(f: A => B): Tr[B] = ??? | ||
|
||
|
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,4 +1,4 @@ | ||
|
||
import language.postfixOps | ||
object Test { | ||
val I1: Int = 0 * * * 8 * 1 - 1 + 1 + // 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import language.postfixOps | ||
class x0[x1] { | ||
def x2: x1 | ||
} | ||
|
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,4 +1,4 @@ | ||
|
||
import language.postfixOps | ||
trait T { | ||
def f = 3_14_E-2 // error | ||
def e = 3_14E-_2 // error | ||
|
This file was deleted.
Oops, something went wrong.
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,8 +1,9 @@ | ||
import scala.concurrent.duration.* | ||
|
||
import scala.language.postfixOps | ||
|
||
def test() = { | ||
// only OK since the defaultOptions in the TestConfiguration includes -language:postfixOps | ||
1 second | ||
|
||
Seq(1, 2).filter(List(1,2) contains) | ||
} | ||
Seq(1, 2) filter (List(1,2) contains) toList | ||
} |
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,3 +1,4 @@ | ||
import language.postfixOps | ||
object desugar { | ||
|
||
// variables | ||
|
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
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.
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.
I wonder whether just changing there the value of
maybePostfix
toin.postfixOpsEnabled
wouldn't do the same as all these parser changes.I mean, this is the only place where we set
ParseKind.Expr
so instead of checking if the postfix is enabled ininfixOps
, we can do it here.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.
No, since even with postfixOpsEnabled we do not allow postfix ops in patterns and types.
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.
Yes, but for these cases the
maybePostfix
parameter was already by defaultfalse
.