Skip to content

Commit 04bb9d6

Browse files
committed
parse.y: save cmdarg_stack in local scope
* parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to isolate command argument state from outer scope. [ruby-core:59342] [Bug #9308] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent bb4a1ac commit 04bb9d6

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat Dec 28 00:42:37 2013 Nobuyoshi Nakada <[email protected]>
2+
3+
* parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to
4+
isolate command argument state from outer scope.
5+
[ruby-core:59342] [Bug #9308]
6+
17
Fri Dec 27 13:25:03 2013 NAKAMURA Usaku <[email protected]>
28

39
* win32/{setup.mak,Makefile.sub}: update fake.rb like

parse.y

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct local_vars {
130130
struct vtable *vars;
131131
struct vtable *used;
132132
struct local_vars *prev;
133+
stack_type cmdargs;
133134
};
134135

135136
#define DVARS_INHERIT ((void*)1)
@@ -9647,6 +9648,8 @@ local_push_gen(struct parser_params *parser, int inherit_dvars)
96479648
local->used = !(inherit_dvars &&
96489649
(ifndef_ripper(compile_for_eval || e_option_supplied(parser))+0)) &&
96499650
RTEST(ruby_verbose) ? vtable_alloc(0) : 0;
9651+
local->cmdargs = cmdarg_stack;
9652+
cmdarg_stack = 0;
96509653
lvtbl = local;
96519654
}
96529655

@@ -9660,6 +9663,7 @@ local_pop_gen(struct parser_params *parser)
96609663
}
96619664
vtable_free(lvtbl->args);
96629665
vtable_free(lvtbl->vars);
9666+
cmdarg_stack = lvtbl->cmdargs;
96639667
xfree(lvtbl);
96649668
lvtbl = local;
96659669
}

test/ruby/test_syntax.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ def test_do_block_in_cmdarg_begin
256256
assert_valid_syntax("p begin 1.times do 1 end end", __FILE__, bug6419)
257257
end
258258

259+
def test_do_block_in_call_args
260+
bug9308 = '[ruby-core:59342] [Bug #9308]'
261+
assert_valid_syntax("bar def foo; self.each do end end", bug9308)
262+
end
263+
259264
def test_reserved_method_no_args
260265
bug6403 = '[ruby-dev:45626]'
261266
assert_valid_syntax("def self; :foo; end", __FILE__, bug6403)

0 commit comments

Comments
 (0)