gleam-lang / tree-sitter-gleam

🌳 A tree-sitter grammar for the Gleam programming language
Apache License 2.0
71 stars 13 forks source link

parse implicit discard '..' as '$.list_pattern_tail' #3

Closed the-mikedavis closed 2 years ago

the-mikedavis commented 2 years ago

I noticed this syntax in the language tour docs and saw that it's throwing up an (ERROR) node currently:

case xs {
  [[]] -> "The only element is an empty list"
  [[], ..] -> "The 1st element is an empty list"
  [[4], ..] -> "The 1st element is a list of the number 4"
  other -> "Something else"
}

I think the gleam parser has a clause for this case here, so I went and made the binding pattern optional

J3RN commented 2 years ago

Ah, great catch! :100: The lines you specified return a parse_error, I think you meant the Some(None) match arm directly below that one :grin: