Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Not A Bug
-
Affects Version/s: JRuby 1.5
-
Fix Version/s: None
-
Component/s: Interpreter
-
Labels:None
-
Environment:WinXp (untested elsewhere)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
-
Number of attachments :
Description
Problem defining method with default param in first position. Seems OK for 1.9. See below:
C:\>jruby --1.9 -S jirb
irb(main):001:0> def qtest(a="foo",b);puts "hello";end;qtest(1,2)
hello
=> nil
irb(main):002:0> exit
C:\>jruby -S jirb
irb(main):001:0> def qtest(a="foo",b);puts "hello";end;qtest(1,2)
SyntaxError: (irb):1: syntax error, unexpected tRPAREN
def qtest(a="foo",b);puts "hello";end;qtest(1,2)
^
from (irb):1
irb(main):002:0> def qtest(a,b);puts "hello";end;qtest(1,2)
hello
=> nil
irb(main):003:0> def qtest(a,b="bar");puts "hello";end;qtest(1,2)
hello
=> nil
irb(main):004:0> def qtest(a="foo",b="bar");puts "hello";end;qtest(1,2)
hello
=> nil
irb(main):005:0> def qtest(a="foo",b);puts "hello";end;qtest(1,2)
SyntaxError: (irb):5: syntax error, unexpected tRPAREN
def qtest(a="foo",b);puts "hello";end;qtest(1,2)
^
from (irb):5
Hi, I'm closing this because it's not a bug.
In ruby 1.8 is not allowed to put parameters without a default value after one with default value, this is the same example in MRI:
irb(main):001:0> def qtest(a="foo",b);puts "hello";end;qtest(1,2) SyntaxError: compile error (irb):1: syntax error, unexpected ')', expecting '=' def qtest(a="foo",b);puts "hello";end;qtest(1,2) ^ (irb):1: syntax error, unexpected kEND, expecting $end def qtest(a="foo",b);puts "hello";end;qtest(1,2) ^ from (irb):1 irb(main):002:0>