Skip to content

JRuby 9.4.0.0 Anonymous block argument after a splat is broken #7506

@jimtng

Description

@jimtng
irb(main):001:0> JRUBY_VERSION
=> "9.4.0.0"
irb(main):002:0> def test(&); end
=> :test
irb(main):003:0> def test(plain, &); end
=> :test
irb(main):004:0> def test(*x, &); end
org/jruby/RubyKernel.java:1143:in `eval': (irb):4: ... after rest argument (SyntaxError)
def test(*x, &); end
              ^
	from org/jruby/RubyKernel.java:1586:in `loop'
	from org/jruby/RubyKernel.java:1292:in `catch'
	from org/jruby/RubyKernel.java:1292:in `catch'
	from /home/openhab/.rbenv/versions/jruby-9.4.0.0/lib/ruby/gems/shared/gems/irb-1.4.1/exe/irb:11:in `<main>'
	from org/jruby/RubyKernel.java:1091:in `load'
	from /home/openhab/.rbenv/versions/jruby-9.4.0.0/bin/irb:23:in `<main>'
irb(main):005:0> def test(**x, &); end
=> :test
irb(main):006:0> def test(*x, **y, &); end
org/jruby/RubyKernel.java:1143:in `eval': (irb):6: ... after rest argument (SyntaxError)
def test(*x, **y, &); end
                   ^
	from org/jruby/RubyKernel.java:1586:in `loop'
	from org/jruby/RubyKernel.java:1292:in `catch'
	from org/jruby/RubyKernel.java:1292:in `catch'
	from /home/openhab/.rbenv/versions/jruby-9.4.0.0/lib/ruby/gems/shared/gems/irb-1.4.1/exe/irb:11:in `<main>'
	from org/jruby/RubyKernel.java:1091:in `load'
	from /home/openhab/.rbenv/versions/jruby-9.4.0.0/bin/irb:23:in `<main>'

Rubocop when set to 3.1 TargetRubyVersion will rewrite code into anonymous block syntax which caused errors in jruby 9.4.0.0.

My current workaround is adding this to .rubocop.yml

# This is needed because jruby 9.4.0.0 doesn't support anonymous block forwarding.
# Remove when jruby supports it again
Naming/BlockForwarding:
  EnforcedStyle: explicit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions