alex-pinkus/tree-sitter-swift

Optional assignment fails to parse

nmote opened this issue · 3 comments

nmote commented

I added this test case to my local copy, which passes, but it should not have the ERROR nodes:

================================================================================
Optional assignment
================================================================================

a.b? = 1
c? = 2

--------------------------------------------------------------------------------

(source_file
  (navigation_expression
    (simple_identifier)
    (navigation_suffix
      (simple_identifier)))
  (ERROR
    (integer_literal))
  (simple_identifier)
  (ERROR
    (integer_literal)))

I don't know what this syntax is actually called in Swift, but it basically does the assignment only if the value on the left hand side is not nil.

nmote commented

I took a stab at this but quickly ran into conflicts which were not easily solved. I'll revisit it if I have a chance.

I will take a look at this this weekend.

nmote commented

I'm looking forward to seeing what you come up with. I tried a few different things and none worked.