ruby-lex hangs if there is no newline at end of file
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]
Updated by mame (Yusuke Endoh) over 9 years ago
- Status changed from Open to Closed
This is maybe fixed at r27303, though I cannot confirm it
because OP does not explain the process to reproduce the
At least, I confirmed that the following terminated now:
$ echo -n "x = 1; x + x" | irb
Yusuke Endoh firstname.lastname@example.org
Updated by jmthomas (Jason Thomas) about 9 years 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:
lex = RubyLex.new
while token = lex.token
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.