Skip to content

Incompatible error when nested LoadError #7316

@koic

Description

@koic

Environment Information

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
% ruby -v
jruby 9.3.7.0 (2.6.8) 2022-08-16 c79ef237e0 Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit [x86_64-darwin]
  • Operating system and platform (e.g. uname -a)
% uname -a
Darwin atelier.local 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

Other relevant info you may wish to add:

This is a reproduction case.

% cat example.rb
begin
  require 'feature-foo'
rescue ::LoadError => e1
  begin
    require 'feature/foo'
  rescue ::LoadError => e2
    raise e1 # NOTE: Raise `LoadError` if `e2` instead of `e1`.
  end
end

Expected Behavior

Raise LoadError.

JRuby 9.3.1.0:

% ruby example.rb
LoadError: no such file to load -- feature-foo
  require at org/jruby/RubyKernel.java:1017
  require at /Users/koic/.rbenv/versions/jruby-9.3.1.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
   <main> at example.rb:2

Same LoadError in JRuby 9.3.0.0 and MRI.

Actual Behavior

Raise RuntimeError.

JRuby 9.3.4.0 or higher:

% ruby example.rb
RuntimeError: circular causes
  <main> at example.rb:7
LoadError: no such file to load -- feature/foo
  require at org/jruby/RubyKernel.java:1017
  require at /Users/koic/.rbenv/versions/jruby-9.3.4.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
   <main> at example.rb:5
LoadError: no such file to load -- feature-foo
  require at org/jruby/RubyKernel.java:1017
  require at /Users/koic/.rbenv/versions/jruby-9.3.4.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
   <main> at example.rb:2

It may be a regression caused by resolving the recursion error that occurred in JRuby 9.3.2.0 and 9.3.3.0.

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