Skip to content

Allow block before lambda_expression #54

Closed
@ptwales

Description

@ptwales

This is sort of not conventional but is valid:

val foo: Int => Int = { x => 
  val y = 2 * x
  y * y
}

Output from playground:

val_definition [0, 0] - [3, 1]
  pattern: identifier [0, 4] - [0, 7]
  type: function_type [0, 9] - [0, 19]
    parameter_types: parameter_types [0, 9] - [0, 12]
      type_identifier [0, 9] - [0, 12]
    return_type: type_identifier [0, 16] - [0, 19]
  value: block [0, 22] - [3, 1]
    lambda_expression [0, 24] - [1, 15]
      identifier [0, 24] - [0, 25]
      assignment_expression [1, 2] - [1, 15]
        left: postfix_expression [1, 2] - [1, 7]
          identifier [1, 2] - [1, 5]
          identifier [1, 6] - [1, 7]
        right: infix_expression [1, 10] - [1, 15]
          left: integer_literal [1, 10] - [1, 11]
          operator: operator_identifier [1, 12] - [1, 13]
          right: identifier [1, 14] - [1, 15]
    infix_expression [2, 2] - [2, 7]
      left: identifier [2, 2] - [2, 3]
      operator: operator_identifier [2, 4] - [2, 5]
      right: identifier [2, 6] - [2, 7]

I don't know what this should parse to but val y should be a val_definition and not a post_fix_expression

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