mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Should not warn massign parameters as unused
This commit is contained in:
parent
a17fba6989
commit
27723b699b
2 changed files with 8 additions and 4 deletions
2
parse.y
2
parse.y
|
@ -404,6 +404,7 @@ static NODE *literal_concat(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
|
|||
static NODE *new_evstr(struct parser_params*,NODE*,const YYLTYPE*);
|
||||
static NODE *evstr2dstr(struct parser_params*,NODE*);
|
||||
static NODE *splat_array(NODE*);
|
||||
static void mark_lvar_used(struct parser_params *p, NODE *rhs);
|
||||
|
||||
static NODE *call_bin_op(struct parser_params*,NODE*,ID,NODE*,const YYLTYPE*,const YYLTYPE*);
|
||||
static NODE *call_uni_op(struct parser_params*,NODE*,ID,const YYLTYPE*,const YYLTYPE*);
|
||||
|
@ -3150,6 +3151,7 @@ f_marg : f_norm_arg
|
|||
{
|
||||
/*%%%*/
|
||||
$$ = assignable(p, $1, 0, &@$);
|
||||
mark_lvar_used(p, $$);
|
||||
/*% %*/
|
||||
/*% ripper: assignable(p, $1) %*/
|
||||
}
|
||||
|
|
|
@ -961,10 +961,12 @@ x = __ENCODING__
|
|||
assert_warning(/assigned but unused variable/) {o.instance_eval("def foo; a=1; nil; end")}
|
||||
assert_warning(/assigned but unused variable/) {o.instance_eval("def bar; a=1; a(); end")}
|
||||
a = "\u{3042}"
|
||||
assert_warning(/#{a}/) {o.instance_eval("def foo; #{a}=1; nil; end")}
|
||||
o = Object.new
|
||||
assert_warning(/assigned but unused variable/) {o.instance_eval("def foo; tap {a=1; a()}; end")}
|
||||
assert_warning('') {o.instance_eval("def bar; a=a=1; nil; end")}
|
||||
assert_warning(/#{a}/) {o.instance_eval("def foo0; #{a}=1; nil; end")}
|
||||
assert_warning(/assigned but unused variable/) {o.instance_eval("def foo1; tap {a=1; a()}; end")}
|
||||
assert_warning('') {o.instance_eval("def bar1; a=a=1; nil; end")}
|
||||
assert_warning(/assigned but unused variable/) {o.instance_eval("def bar2; a, = 1, 2; end")}
|
||||
assert_warning('') {o.instance_eval("def marg1(a); nil; end")}
|
||||
assert_warning('') {o.instance_eval("def marg2((a)); nil; end")}
|
||||
end
|
||||
|
||||
def test_named_capture_conflict
|
||||
|
|
Loading…
Reference in a new issue