parse.y: rescue modifier in rhs
* parse.y (command_asgn): rescue modifier in command assignment should be limited to rhs only. [ruby-core:75621] [Bug #12402] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
89ab385b17
commit
064ed74be4
@ -1,3 +1,8 @@
|
|||||||
|
Wed Aug 10 17:26:43 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (command_asgn): rescue modifier in command assignment
|
||||||
|
should be limited to rhs only. [ruby-core:75621] [Bug #12402]
|
||||||
|
|
||||||
Wed Aug 10 15:35:03 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Aug 10 15:35:03 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/win32/resolv/resolv.c: needs windows.h for iphlpapi.h on
|
* ext/win32/resolv/resolv.c: needs windows.h for iphlpapi.h on
|
||||||
|
12
parse.y
12
parse.y
@ -1357,6 +1357,18 @@ command_asgn : lhs '=' command_call
|
|||||||
$$ = dispatch2(assign, $1, $3);
|
$$ = dispatch2(assign, $1, $3);
|
||||||
%*/
|
%*/
|
||||||
}
|
}
|
||||||
|
| lhs '=' command_call modifier_rescue stmt
|
||||||
|
{
|
||||||
|
/*%%%*/
|
||||||
|
NODE *resq = NEW_RESBODY(0, remove_begin($5), 0);
|
||||||
|
value_expr($3);
|
||||||
|
resq = NEW_RESCUE($3, resq, 0);
|
||||||
|
$$ = node_assign($1, resq);
|
||||||
|
/*%
|
||||||
|
$3 = dispatch2(rescue_mod, $3, $5);
|
||||||
|
$$ = dispatch2(assign, $1, $3);
|
||||||
|
%*/
|
||||||
|
}
|
||||||
| lhs '=' command_asgn
|
| lhs '=' command_asgn
|
||||||
{
|
{
|
||||||
/*%%%*/
|
/*%%%*/
|
||||||
|
@ -874,6 +874,16 @@ x = __ENCODING__
|
|||||||
assert_warning('') {eval("#{a} = 1; /(?<#{a}>)/ =~ ''")}
|
assert_warning('') {eval("#{a} = 1; /(?<#{a}>)/ =~ ''")}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_rescue_in_command_assignment
|
||||||
|
bug = '[ruby-core:75621] [Bug #12402]'
|
||||||
|
v = bug
|
||||||
|
v = raise(v) rescue "ok"
|
||||||
|
assert_equal("ok", v)
|
||||||
|
v = bug
|
||||||
|
v = raise v rescue "ok"
|
||||||
|
assert_equal("ok", v)
|
||||||
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
def test_past_scope_variable
|
def test_past_scope_variable
|
||||||
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
|
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user