-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
- Supports Ruby 2.0+ runtime #986
Conversation
This is an alternative approach to the changes in whitequark#985. The Parser gem may be required to operate across as many Ruby versions as possible. The use of `delete_suffix` starts from Parser version 3.3.0.0. Therefore, by replacing `delete_suffix` with `sub`, and releasing Parser 3.3.0.1, supporting Ruby 2.0 would be feasible.
Ruby 2.0.0 has reached EOL at |
For example, Ruby Next is used in a transpiler that allows for using new Ruby syntax on older Ruby runtimes. It seems to support Ruby 2.2+. There are also users who cannot necessarily move away from EOL versions. Considering that the Parser gem is arguably the most utilized Ruby parser implementation, I think there is worth in supporting older Ruby runtimes as much as possible. On the other hand, I deeply regret that this comes at the cost of not being able to use newer language features 🙇 |
Ok, fair enough |
I've released |
Thank you for considering this matter. |
…2.3 (rmagick#1422)" The parser gem has still support Ruby 2.0+ whitequark/parser#986 This reverts commit 6f906a8.
…2.3 (#1422)" (#1425) The parser gem has still supported Ruby 2.0+ whitequark/parser#986 This reverts commit 6f906a8.
It's not clear to me why someone with a very old Ruby would want to use later versions of Nevertheless, if this comes up from time to time, consider using |
I've found whitequark#986 regressions in the following RuboCop CI matrix: https://github.com/rubocop/rubocop/actions/runs/7437077900/job/20234293932?pr=12598 So, whitequark#986 was not a sufficient fix. This PR fixes an error when using heredoc with non-word delimiters: ```ruby <<~'+' foo + ``` The following repro test have been newly added: ```console $ 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' ```
I've found whitequark#986 regression in the following RuboCop CI matrix: https://github.com/rubocop/rubocop/actions/runs/7437077900/job/20234293932?pr=12598 So, whitequark#986 was not a sufficient fix. This PR fixes an error when using heredoc with non-word delimiters: ```ruby <<~'+' foo + ``` The following repro test have been newly added: ```console $ 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' ```
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: ```ruby <<~'+' foo + ``` The following repro test have been newly added: ```console $ 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' ```
these users can also do core extensions to do a "single method" backport if needed. I personally would not regress my own project for these users. |
This is an alternative approach to the changes in #985. The Parser gem may be required to operate across as many Ruby versions as possible. The use of
delete_suffix
starts from Parser version 3.3.0.0. Therefore, by replacingdelete_suffix
withsub
, and releasing Parser 3.3.0.1, supporting Ruby 2.0 would be feasible.