Project

General

Profile

Actions

Bug #6378

closed

irb incorrectly considers line incomplete when parenthesis are excluded

Added by devans (Daniel Evans) almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.2.0]
Backport:
[ruby-core:44753]

Description

Steps to reproduce:

start irb
attempt to execute the following line:
[1,2,3].reduce :+

Expected:
a result of => 6 should be printed and a new line should be available

Actual:
The result is not printed and the shell indicates more lines are expected

irb(main):001:0> [1,2,3].reduce :+
irb(main):002:0*

Workaround:
add parenthesis to the method call:
[1,2,3].reduce(:+)

Notes:
The line is executed, as evidenced by changing the symbol to represent a message to which FixNum does not respond, such as :_ after which the error message will be printed immediately.

This is also reproducible in ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]

irb versions tested:
irb 0.9.6(09/06/30)
irb 0.9.5(05/04/13)

Updated by mame (Yusuke Endoh) almost 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to keiju (Keiju Ishitsuka)

Thanks, assigning it to keiju who is a developer/maintainer of irb.

--
Yusuke Endoh

Updated by devans (Daniel Evans) almost 12 years ago

I noticed while working today that this only affects certain symbols, particularly :+ and :-

If you attempt the same code with :* it works perfectly.

irb(main):001:0> [1,2,3,4].reduce :-
irb(main):002:0* ^D
irb(main):002:0> [1,2,3,4].reduce :+
irb(main):003:0* ^D
irb(main):003:0> [1,2,3,4].reduce :*
=> 24
irb(main):004:0>

Actions #3

Updated by keiju (Keiju Ishitsuka) over 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38632.
Daniel, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/irb/ruby-lex.rb: make lex_state to EXPR_END when next token
    is an operator after SYMBEG [Bug #6378].
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0