Skip to content

Trailing coma after for comprehension in lambda parameter of a function #449

@susliko

Description

@susliko

Commit of tree-sitter-scala you tested this on

fb999c7

A code sample showing the error

object Foo:
  def foo(f: Option[Int] => Option[Int]): Option[Int] = f(None)

  foo(o =>
    for {
      a <- o
    } yield a,
  )

Show the error node

...
          (lambda_expression ; [3, 6] - [7, 2]
            parameters: (identifier) ; [3, 6] - [3, 7]
            (indented_block ; [4, 4] - [7, 2]
              (for_expression ; [4, 4] - [6, 13]
                enumerators: (enumerators ; [5, 6] - [6, 4]
                  (enumerator ; [5, 6] - [5, 12]
                    (identifier) ; [5, 6] - [5, 7]
                    (identifier))) ; [5, 11] - [5, 12]
                body: (identifier)) ; [6, 12] - [6, 13]
              (ERROR)))))))) ; [6, 13] - [6, 14]
...

What do you expect the tree to look like

          (lambda_expression ; [3, 6] - [7, 2]
            parameters: (identifier) ; [3, 6] - [3, 7]
            (indented_block ; [4, 4] - [7, 2]
              (for_expression ; [4, 4] - [6, 13]
                enumerators: (enumerators ; [5, 6] - [6, 4]
                  (enumerator ; [5, 6] - [5, 12]
                    (identifier) ; [5, 6] - [5, 7]
                    (identifier))) ; [5, 11] - [5, 12]
                body: (identifier))))))))) ; [6, 12] - [6, 13]

Where are you experiencing this error?

nvim-treesitter

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions