Bug #2763

ruby-lex hangs if there is no newline at end of file

Added by Jason Thomas almost 2 years ago. Updated 10 months ago.

[ruby-core:28248]
Status:Closed Start date:02/19/2010
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:core
Target version:-
ruby -v:ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]

Description

When calling RubyLex.token in a while loop, the parser spins returning TkIDENTIFIER if there is no newline at the end of the file. This bug is related to the following issue in RubyForge: http://rubyforge.org/tracker/?group_id=426&atid=1698&func=detail&aid=1745. This was fixed but seems to be reintroduced in Ruby 1.9.

ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]

History

Updated by Yusuke Endoh almost 2 years ago

  • Status changed from Open to Closed
Hi,

This is maybe fixed at r27303, though I cannot confirm it
because OP does not explain the process to reproduce the
issue.

At least, I confirmed that the following terminated now:

  $ echo -n "x = 1; x + x" | irb

Thanks.

-- 
Yusuke Endoh <mame@tsg.ne.jp>

Updated by Jason Thomas over 1 year ago

I verified this bug exists in ruby-1.9.1-p378 on my Mac but has been fixed in ruby-1.9.2-rc2. Here is some example code to show the problem:

require 'irb/ruby-lex'
lex = RubyLex.new
lex.set_input(File.open("test.rb"))
while token = lex.token
  puts token
end

If test.rb does not have a newline at the end of the file it will loop endlessly in 1.9.1 but not in 1.9.2-rc2.

Also available in: Atom PDF