-
-
Notifications
You must be signed in to change notification settings - Fork 939
Closed
Milestone
Description
#!/usr/bin/env ruby
class A
def shift(count)
it = "hi"
puts it.inspect
count.times do
puts it.inspect
break unless it.length == 1
end
"bye"
end
end
A.new.shift(3)Environment Information
jruby 10.0.0.0 (3.4.2) 2025-04-13 6ed59bc OpenJDK 64-Bit Server VM 21.0.6+7-Ubuntu-124.04.1 on 21.0.6+7-Ubuntu-124.04.1 +indy +jit [x86_64-linux]
Expected Behavior
Expected output (and actual output from JRuby 9.4.12.0 and CRuby 3.4.2):
"hi"
"hi"
Actual Behavior
Actual output:
"hi"
0
NoMethodError: undefined method 'length' for an instance of Integer
shift at ./test.rb:9
times at org/jruby/RubyFixnum.java:343
shift at ./test.rb:7
<main> at ./test.rb:15
It seems that it in the block is referring to the special block variable, even though a local of the same name already exists (which apparently makes the special block variable not created in CRuby?)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels