-
-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Ripper error when using Ruby 2.5's rescue
inside do
/end
blocks without begin
syntax
#6642
Milestone
Comments
koic
added a commit
to koic/rubocop
that referenced
this issue
Mar 31, 2021
Workaround for jruby/jruby#6642. This commits prevent the following error when using JRuby 9.2. ```console % ruby -v jruby 9.2.17.0 (2.5.8) 2021-03-29 84d363da97 Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit [darwin-x86_64] % bundle exec rake documentation_syntax_check [warn]: Syntax error in `lib/rubocop/cop/lint/shadowed_exception.rb`:(118,18): syntax error, unexpected keyword_rescue [warn]: ParserSyntaxError: syntax error in `lib/rubocop/cop/lint/shadowed_exception.rb`:(118,18): syntax error, unexpected keyword_rescue [warn]: Stack trace: /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/ruby/ruby_parser.rb:601:in `on_parse_error' org/jruby/ext/ripper/RubyRipper.java:347:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/ruby/ruby_parser.rb:56:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/ruby/ruby_parser.rb:17:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/source_parser.rb:442:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/source_parser.rb:46:in `block in parse' Files: 569 Modules: 88 ( 13 undocumented) Classes: 531 ( 2 undocumented) Constants: 892 ( 879 undocumented) Attributes: 31 ( 0 undocumented) Methods: 1186 ( 1060 undocumented) 28.37% documented rake aborted! NoMethodError: undefined method `each' for nil:NilClass /Users/koic/src/github.com/rubocop/rubocop/Rakefile:105:in `block in /Users/koic/src/github.com/rubocop/rubocop/Rakefile' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/registry.rb:207:in `each' /Users/koic/src/github.com/rubocop/rubocop/Rakefile:96:in `block in <main>' /Users/koic/.rbenv/versions/jruby-9.2.17.0/bin/bundle:23:in `<main>' Tasks: TOP => documentation_syntax_check (See full trace by running task with --trace) ```
bbatsov
pushed a commit
to rubocop/rubocop
that referenced
this issue
Apr 5, 2021
Workaround for jruby/jruby#6642. This commits prevent the following error when using JRuby 9.2. ```console % ruby -v jruby 9.2.17.0 (2.5.8) 2021-03-29 84d363da97 Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit [darwin-x86_64] % bundle exec rake documentation_syntax_check [warn]: Syntax error in `lib/rubocop/cop/lint/shadowed_exception.rb`:(118,18): syntax error, unexpected keyword_rescue [warn]: ParserSyntaxError: syntax error in `lib/rubocop/cop/lint/shadowed_exception.rb`:(118,18): syntax error, unexpected keyword_rescue [warn]: Stack trace: /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/ruby/ruby_parser.rb:601:in `on_parse_error' org/jruby/ext/ripper/RubyRipper.java:347:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/ruby/ruby_parser.rb:56:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/ruby/ruby_parser.rb:17:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/source_parser.rb:442:in `parse' /Users/koic/.rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/yard-0.9.26/lib/yard/parser/source_parser.rb:46:in `block in parse' Files: 569 Modules: 88 ( 13 undocumented) Classes: 531 ( 2 undocumented) Constants: 892 ( 879 undocumented) Attributes: 31 ( 0 undocumented) Methods: 1186 ( 1060 undocumented) 28.37% documented rake aborted! NoMethodError: undefined method `each' for nil:NilClass /Users/koic/src/github.com/rubocop/rubocop/Rakefile:105:in `block in /Users/koic/src/github.com/rubocop/rubocop/Rakefile' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/registry.rb:207:in `each' /Users/koic/src/github.com/rubocop/rubocop/Rakefile:96:in `block in <main>' /Users/koic/.rbenv/versions/jruby-9.2.17.0/bin/bundle:23:in `<main>' Tasks: TOP => documentation_syntax_check (See full trace by running task with --trace) ```
It still reproduces in JRuby 9.3.0.0. % ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin19]
% ruby example.rb # no errors.
% ruby -v
jruby 9.3.0.0 (2.6.8) 2021-09-17 85c20e780f Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit
% ruby example.rb
RuntimeError: syntax error, unexpected rescue
on_parse_error at example.rb:6
parse at org/jruby/ext/ripper/RubyRipper.java:342
<main> at example.rb:10 |
koic
added a commit
to koic/rubocop
that referenced
this issue
Jun 3, 2023
## Summary Revert rubocop@1533ece Current RuboCop (1.52) requires Ruby 2.7+ and JRuby 9.4+. So JRuby 9.2 has been dropped from runtime version. ## Additional Information jruby/jruby#6642 has been resolved in JRuby 9.4: ```ruby # example.rb require 'ripper' class RipperParser < Ripper def on_parse_error(message) raise message end end RipperParser.new(<<~RUBY).parse foo do bar do end rescue NameError converted << nil end RUBY ``` ```console $ ruby -v jruby 9.4.2.0 (3.1.0) 2023-03-08 90d2913fda Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit [x86_64-darwin] $ ruby example.rb # No errors ```
8 tasks
This issue has been resolved in JRuby 9.4: $ ruby -v
jruby 9.4.2.0 (3.1.0) 2023-03-08 90d2913fda Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit [x86_64-darwin]
$ ruby example.rb # No errors Thank you! |
bbatsov
pushed a commit
to rubocop/rubocop
that referenced
this issue
Jun 4, 2023
## Summary Revert 1533ece Current RuboCop (1.52) requires Ruby 2.7+ and JRuby 9.4+. So JRuby 9.2 has been dropped from runtime version. ## Additional Information jruby/jruby#6642 has been resolved in JRuby 9.4: ```ruby # example.rb require 'ripper' class RipperParser < Ripper def on_parse_error(message) raise message end end RipperParser.new(<<~RUBY).parse foo do bar do end rescue NameError converted << nil end RUBY ``` ```console $ ruby -v jruby 9.4.2.0 (3.1.0) 2023-03-08 90d2913fda Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit [x86_64-darwin] $ ruby example.rb # No errors ```
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Environment Information
Provide at least:
jruby -v
) and command line (flags, JRUBY_OPTS, etc)uname -a
)Expected Behavior
The following is an example:
This is behavior of MRI 2.5.8.
No errors.
Actual Behavior
This is behavior of JRuby 9.2.17.0.
Unexpectedly, JRuby 9.2.17.0 raises the
RuntimeError
.I encountered this issue in YARD on which RuboCop depends.
rubocop/rubocop#9648
The text was updated successfully, but these errors were encountered: