1
0
Fork 0
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:
Nobuyoshi Nakada 2019-06-29 18:45:24 +09:00
parent a17fba6989
commit 27723b699b
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 8 additions and 4 deletions

View file

@ -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) %*/
}

View file

@ -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