{{ message }}
Add (lambda_expression) without bindings to locals.scm.#346
Open
rwjblue wants to merge 1 commit intotree-sitter:masterfrom
Open
Add (lambda_expression) without bindings to locals.scm.#346rwjblue wants to merge 1 commit intotree-sitter:masterfrom
(lambda_expression) without bindings to locals.scm.#346rwjblue wants to merge 1 commit intotree-sitter:masterfrom
Conversation
When you have a lambda expression like:
```scala
val fruits = List("apple", "banana", "avocado", "papaya")
val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))
for ((count, fruits) <- countsToFruits) {
println(s"with (fruits) 'a' × $count = $fruits")
}
```
The `fruit => fruit.count(_ == 'a')` lambda expression (note: without
wrapping parenthesis) does not create a `(binding)` node. Its syntax
tree is:
```
(lambda_expression) ; [5:18 - 47]
parameters: (identifier) ; [5:18 - 22]
(call_expression) ; [5:27 - 47]
function: (field_expression) ; [5:27 - 37]
value: (identifier) ; [5:27 - 31]
field: (identifier) ; [5:33 - 37]
arguments: (arguments) ; [5:38 - 47]
(infix_expression) ; [5:39 - 46]
left: (wildcard) ; [5:39 - 39]
operator: (operator_identifier) ; [5:41 - 42]
right: (character_literal) ; [5:44 - 46]
```
That example just _happens_ to be **exactly** one of the example from
https://www.scala-lang.org/ ([see playground](https://scastie.scala-lang.org/S0bkCiXkQiuOMXnlhWn46g)) 😁.
ckipp01
reviewed
Sep 18, 2023
Collaborator
ckipp01
left a comment
There was a problem hiding this comment.
Thanks for this @rwjblue! If I'm not mistaken can you try to add this to some of the hightlight query tests which should verify that this indeed is capturing the way we'd want.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

When you have a lambda expression like:
The
fruit => fruit.count(_ == 'a')lambda expression (note: without wrapping parenthesis) does not create a(binding)node. Its syntax tree is:That example just happens to be exactly one of the example from https://www.scala-lang.org/ (see playground) 😁.