whitequark / parser

A Ruby parser.
Other
1.57k stars 197 forks source link

- Fix an error when using heredoc with non-word delimiters #987

Closed koic closed 6 months ago

koic commented 6 months ago

I've found #986 regression in the following RuboCop CI matrix: https://github.com/rubocop/rubocop/actions/runs/7437077900/job/20234293932?pr=12598

So, #986 was not a sufficient fix. This PR fixes an error when using heredoc with non-word delimiters:

<<~'+'
  foo
+

The following repro test have been newly added:

$ bundle exec ruby -Itest test/test_lexer.rb
(snip)

  1) Error:
TestLexer#test_heredoc_plus_character:
RegexpError: target of repeat operator is not specified: /+\z/
    /Users/koic/src/github.com/whitequark/parser/lib/parser/lexer/literal.rb:250:in `delimiter?'
    /Users/koic/src/github.com/whitequark/parser/lib/parser/lexer/literal.rb:138:in `nest_and_try_closing'
    /Users/koic/src/github.com/whitequark/parser/lib/parser/lexer-strings.rb:4165:in `advance'
    /Users/koic/src/github.com/whitequark/parser/lib/parser/lexer-F1.rb:11369:in `advance'
    test/test_lexer.rb:81:in `assert_scanned'
    test/test_lexer.rb:1001:in `test_heredoc_plus_character'
iliabylich commented 6 months ago

Thanks, I've released 3.3.0.2