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
Try any expression #8071
Try any expression #8071
Conversation
Previously, parsing `try` was special-cased for expressions beginning with paren or brace. Perhaps that was to avoid odd sights such as `try (1,2,3)` or `try { case _ => }`, but it also broke `try { 1 } + 1 finally ()`. This commit takes an arbitrary expression to `try`.
Try any patch twice. |
case FINALLY => in.nextToken(); expr() | ||
case _ => EmptyTree | ||
case FINALLY => in.nextToken() ; expr() | ||
case _ => EmptyTree |
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.
We don't need scalafmt, just somfmt.
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'd changed it to if-else in the earlier patch, but now I always prefer match. This is how I typed it back in.
|
||
// was: value isDefinedAt is not a member of Int | ||
// now: required: PartialFunction[Throwable,?] | ||
//def f = try ??? catch 22 |
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 a good error message. Why not test it?
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 will come back with the change to catch
, which I'll attempt thricely.
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.
Pardon, this is the third time, not so much charmed as cut off at the knees. The next try for catch will be a fourth.
@hrhino this is when I laughed again at your previous comment. |
Previously, parsing
try
was special-cased for expressionsbeginning with paren or brace. Perhaps that was to avoid odd
sights such as
try (1,2,3)
ortry { case _ => }
, but italso broke
try { 1 } + 1 finally ()
.This commit takes an arbitrary expression to
try
.This is just the parser change for
try
from #4400Fixes scala/bug#5887