-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use p* for vararg splices #11240
Use p* for vararg splices #11240
Conversation
@liufengyun Can you do a technical review for this? |
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
@@ -297,7 +297,7 @@ PatVar ::= varid | |||
| ‘_’ | |||
Patterns ::= Pattern {‘,’ Pattern} | |||
ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ Apply(fn, pats) | |||
| ‘(’ [Patterns ‘,’] Pattern2 ‘:’ ‘_’ ‘*’ ‘)’ | |||
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ |
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 syntax deviates from Scala 2.
I think it would be good to change it to:
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ | |
| ‘(’ [Patterns ‘,’] id ‘*’ ‘)’ |
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 think that's orthogonal to this PR. I am not sure about that. It's the same as for other ascriptions in patterns. I think they are useful to have.
|
||
``` | ||
ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ | ||
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ |
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.
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ | |
| ‘(’ [Patterns ‘,’] id ‘*’ ‘)’ |
Co-authored-by: Fengyun Liu <[email protected]>
From the doc page:
The syntax of vararg splices in patterns and function arguments has changed. The new syntax uses a postfix
*
, analogously to how a vararg parameter is declared.The old syntax for splice arguments will be phased out.
Syntax
Compatibility considerations
To enable cross compilation between Scala 2 and Scala 3, the compiler will
accept both the old and the new syntax. Under the
-source 3.1
setting, an errorwill be emitted when the old syntax is encountered.
Fixes #11233