Environment Information
jruby 10.0.3.0-SNAPSHOT (3.4.5) 2025-11-30 ffffffffff OpenJDK 64-Bit Server VM 21.0.9+10 on 21.0.9+10 +indy +jit [x86_64-linux] (latest master)
Linux 6.18.4-1-MANJARO #1 SMP PREEMPT_DYNAMIC Thu, 08 Jan 2026 12:46:08 +0000 x86_64 GNU/Linux
Expected Behavior
Given this file a.rb:
A = Class.new(BasicObject)
and running:
jruby -r ./a -e '"#{A.new}"'
I expect NoMethodError: undefined method 'to_s' for an instance of A.
Actual Behavior
Instead, NameError is raised: NameError: undefined local variable or method 'to_s' for an instance of A.
Additional information
- Doing interpolation in the same context, like one file or an IRB session, raises
NoMethodError. Separate file is required.
- Explicitly calling
"#{A.new.to_s}" raises NoMethodError as expected.
Environment Information
jruby 10.0.3.0-SNAPSHOT (3.4.5) 2025-11-30 ffffffffff OpenJDK 64-Bit Server VM 21.0.9+10 on 21.0.9+10 +indy +jit [x86_64-linux](latestmaster)Linux 6.18.4-1-MANJARO #1 SMP PREEMPT_DYNAMIC Thu, 08 Jan 2026 12:46:08 +0000 x86_64 GNU/LinuxExpected Behavior
Given this file
a.rb:and running:
jruby -r ./a -e '"#{A.new}"'I expect
NoMethodError: undefined method 'to_s' for an instance of A.Actual Behavior
Instead,
NameErroris raised:NameError: undefined local variable or method 'to_s' for an instance of A.Additional information
NoMethodError. Separate file is required."#{A.new.to_s}"raisesNoMethodErroras expected.