-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix parenthesized expressions in braceless if
conditions
#350
Fix parenthesized expressions in braceless if
conditions
#350
Conversation
@@ -26,19 +26,19 @@ object Hello { | |||
trait Test { | |||
// ^ keyword | |||
// ^ type | |||
def meth(i: Int)(implicit x: Boolean) = ??? | |||
def meth(i: Int)(implicit x: Boolean) = ??? |
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've made definitions in this trait to be of the same indentation because
trait Foo {
def meth = ???
def anonFun = ???
}
is parsed with an ERROR and this causes flacking of the highlighting test
We might want to open an issue on this, but I'm reluctant to it as scalac
raises a warning for this code
-- Warning: foo.scala:3:2 ------------------------------------------------------
3 | def anonFun = ???
| ^
| Line is indented too far to the left, or a `}` is missing
a9dc60f
to
e8579fa
Compare
// https://github.com/tree-sitter/tree-sitter-scala/issues/263 and | ||
// https://github.com/tree-sitter/tree-sitter-scala/issues/342 | ||
// Neither do I understand why this works, nor have I found a better solution | ||
_if_condition: $ => prec.dynamic(4, choice( |
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'm ashamed of this
Fixes tree-sitter#263 and tree-sitter#342 `_if_condition` extracted from `if_expression` and given a magic dynamic precedence of 4
e8579fa
to
5c54434
Compare
@@ -404,6 +404,11 @@ class C: | |||
else | |||
() | |||
|
|||
if (a) || b(c) then return true |
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.
Nice!
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.
Thanks @susliko!
I've tried this one in the past and gave up, so happy to see this fix.
Fixes #263 and #342
_if_condition
extracted fromif_expression
and given a magic dynamicprecedence of 4