natalie-lang / natalie_parser

NatalieParser is a zero-dependency, from-scratch, hand-written recursive descent parser for the Ruby Programming Language.
MIT License
63 stars 8 forks source link

Reset block association level inside array #13

Closed timcraft closed 2 years ago

timcraft commented 2 years ago

So I found some code like this:

it 'foo' do
  expect(x).to eq(
    [
      [ 1, 2 ],
    ]
  )
end

it 'bar' do
end

Current that raises syntax error, unexpected 'do' (expected: 'end-of-line') because there's no call to m_call_depth.pop() when parsing the array with a trailing comma as there is in the later return.

I've reduced that example as far as I can for the tests, but it needs to have enough structure for the call depth to matter and trigger the bug. I've also added a similar test case and fix for the return statement above the while loop.