local scope in until node
-------------------------
Key: JRUBY-972
URL: http://jira.codehaus.org/browse/JRUBY-972
Project: JRuby
Issue Type: Bug
Components: Interpreter
Environment: JRuby revision 3689
Reporter: Alexey Verkhovsky
Priority: Critical
My theoretical foo is weak, so apologies for expressing this in vague terms.
However... bear with me, this is a very serious bug.
Running the following command in JRuby:
jruby `which rdoc`
~/src/jruby/jruby/lib/ruby/1.8/rdoc/generators/template/html/old_html.rb
creates an endless loop at the following snippet:
begin
line = ""
begin
ch = getc
line << ch
end until ch == "\n"
str << line
end until line =~ /^=end/
which is from lib/ruby/1.8/rdoc/parsers/parse_rb.rb:615-622
It doesn't do so in MRI. Reason is, the value of ch in MRI is reset to null on
every new iteration of the internal loop. Not so in JRuby. In other words,
JRuby puts ch in the wrong scope.
This snippet demonstrates the problem in isolation:
a = [1, 2, 3, 4, 5]
5.times do
begin
ch = a.shift
puts "ch: #{ch}"
end until ch.nil?
print '.'
end
run it in both Ruby and JRuby, and observe that the output is totally different:
[EMAIL PROTECTED]:~$ ruby foo.rb
ch: 1
ch: 2
ch: 3
ch: 4
ch: 5
ch:
.ch:
.ch:
.ch:
.ch:
[EMAIL PROTECTED]:~$ jruby foo.rb
[EMAIL PROTECTED]:~$
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email