From 367118b1b678b83869a9106191cb85197c9ef525 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 21 Apr 2014 10:48:00 +0900 Subject: fix optional arguments in rhs define optional arguments as argument variables in the rhs default expressions, as same as mere assignment expressions. Import ruby/ruby@01740f0c273c89f7bcff3d5014d73c8ff6fb1986 --- test/t/syntax.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/t/syntax.rb b/test/t/syntax.rb index 2adfbc8ab..245c5c099 100644 --- a/test/t/syntax.rb +++ b/test/t/syntax.rb @@ -272,3 +272,20 @@ assert('method definition in cmdarg') do end true end + +assert('optional argument in the rhs default expressions') do + class OptArgInRHS + def foo + "method called" + end + def t(foo = foo) + foo + end + def t2(foo = foo()) + foo + end + end + o = OptArgInRHS.new + assert_nil(o.t) + assert_equal("method called", o.t2) +end -- cgit v1.2.3