mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: warn reference after method definition
* parse.y (primary): restore current_arg so that circular reference after a method definition is also warned. [ruby-core:61299] [Bug #9593] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
db4e9d5eb3
commit
2de3281af4
3 changed files with 20 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Dec 14 20:11:42 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (primary): restore current_arg so that circular
|
||||
reference after a method definition is also warned.
|
||||
[ruby-core:61299] [Bug #9593]
|
||||
|
||||
Sat Dec 13 20:41:55 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm_trace.c (rb_postponed_job_flush): mask signal trap interrupt
|
||||
|
|
4
parse.y
4
parse.y
|
@ -3027,12 +3027,15 @@ primary : literal
|
|||
%*/
|
||||
local_pop();
|
||||
in_def--;
|
||||
current_arg = $<id>3;
|
||||
}
|
||||
| k_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
|
||||
{
|
||||
in_single++;
|
||||
lex_state = EXPR_ENDFN; /* force for args */
|
||||
local_push(0);
|
||||
$<id>$ = current_arg;
|
||||
current_arg = 0;
|
||||
}
|
||||
f_arglist
|
||||
bodystmt
|
||||
|
@ -3048,6 +3051,7 @@ primary : literal
|
|||
%*/
|
||||
local_pop();
|
||||
in_single--;
|
||||
current_arg = $<id>6;
|
||||
}
|
||||
| keyword_break
|
||||
{
|
||||
|
|
|
@ -202,6 +202,16 @@ class TestSyntax < Test::Unit::TestCase
|
|||
o.instance_eval("def foo(var = bar {var}) var end")
|
||||
end
|
||||
|
||||
o = Object.new
|
||||
assert_warn(/circular argument reference - var/) do
|
||||
o.instance_eval("def foo(var = (def bar;end; var)) var end")
|
||||
end
|
||||
|
||||
o = Object.new
|
||||
assert_warn(/circular argument reference - var/) do
|
||||
o.instance_eval("def foo(var = (def self.bar;end; var)) var end")
|
||||
end
|
||||
|
||||
o = Object.new
|
||||
assert_warn("") do
|
||||
o.instance_eval("def foo(var = bar {|var| var}) var end")
|
||||
|
|
Loading…
Reference in a new issue