Skip to content

Fixes instance_expression #131

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 2 commits into from
Jan 12, 2023
Merged

Conversation

eed3si9n
Copy link
Collaborator

Problem

Current grammar accepts expression immeidately after new, which is not correct, and doesn't work for Scala 3 syntax.

Solution

This fixes it by actually using $.template_body. It does create a tricky conflict between new A: <block> construct and new A: <type>.
To deal with that, we are using prec.dynamic.

Problem
-------
Current grammar accepts expression immeidately after `new`,
which is not correct, and doesn't work for Scala 3 syntax.

Solution
--------
This fixes it by actually using `$.template_body`.
It does create a tricky conflict between `new A: <block>`
construct and `new A: <type>`.
To deal with that, we are using `prec.dynamic`.
c = new D(e, f)
val a = new B
val c = new D(e, f)
val e = new E:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity, can you also add an example of the quiet syntax new:

scala> trait Hello:
     |   def x: Int
     |
// defined trait Hello

scala> val x: Hello = new:
     |   def x = 25
     |
val x: Hello = anon$1@6bd92538

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - 14a22e7

Copy link
Collaborator

@keynmol keynmol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@eed3si9n eed3si9n merged commit fd05f09 into tree-sitter:master Jan 12, 2023
@eed3si9n eed3si9n deleted the wip/instance branch January 12, 2023 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants