Skip to content
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

Merged
merged 1 commit into from
Jan 6, 2024
Merged

Conversation

koic
Copy link
Collaborator

@koic koic commented Jan 6, 2024

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 replacing delete_suffix with sub, and releasing Parser 3.3.0.1, supporting Ruby 2.0 would be feasible.

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.
@iliabylich
Copy link
Collaborator

Ruby 2.0.0 has reached EOL at 2016-02-24, what's the reason to keep supporting it? Not saying that it's bad or wrong, but it doesn't let us use any new language features.

@koic
Copy link
Collaborator Author

koic commented Jan 6, 2024

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+.
https://github.com/ruby-next/ruby-next/blob/v1.0.0/ruby-next.gemspec#L28

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 🙇

@iliabylich
Copy link
Collaborator

Ok, fair enough

@iliabylich iliabylich merged commit f754309 into whitequark:master Jan 6, 2024
@koic koic deleted the revert_985 branch January 6, 2024 18:23
@iliabylich
Copy link
Collaborator

I've released 3.3.0.1, just in case anyone needs it

@koic
Copy link
Collaborator Author

koic commented Jan 6, 2024

Thank you for considering this matter.

Watson1978 added a commit to Watson1978/rmagick that referenced this pull request Jan 6, 2024
…2.3 (rmagick#1422)"

The parser gem has still support Ruby 2.0+
whitequark/parser#986

This reverts commit 6f906a8.
Watson1978 added a commit to rmagick/rmagick that referenced this pull request Jan 6, 2024
…2.3 (#1422)" (#1425)

The parser gem has still supported Ruby 2.0+
whitequark/parser#986

This reverts commit 6f906a8.
@marcandre
Copy link
Contributor

It's not clear to me why someone with a very old Ruby would want to use later versions of parser (earlier versions still work and were fine parsing old Ruby code)

Nevertheless, if this comes up from time to time, consider using backports to bring in the methods needed like delete_suffix (or ruby-next/core, but I don't think there's an API for using just a few particular methods)

koic added a commit to koic/parser that referenced this pull request Jan 7, 2024
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'
```
koic added a commit to koic/parser that referenced this pull request Jan 7, 2024
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'
```
iliabylich pushed a commit that referenced this pull request Jan 7, 2024
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'
```
@mbj
Copy link
Collaborator

mbj commented Jan 12, 2024

It's not clear to me why someone with a very old Ruby would want to use later versions of parser (earlier versions still work and were fine parsing old Ruby code)

Nevertheless, if this comes up from time to time, consider using backports to bring in the methods needed like delete_suffix (or ruby-next/core, but I don't think there's an API for using just a few particular methods)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants