mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix segfault when using method reference operator without using result
Fixes [Bug #15985]
This commit is contained in:
parent
688cef2169
commit
f296c260ef
2 changed files with 11 additions and 1 deletions
|
@ -8146,8 +8146,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NODE_METHREF:
|
case NODE_METHREF:
|
||||||
CHECK(COMPILE_(ret, "receiver", node->nd_recv, popped));
|
CHECK(COMPILE(ret, "receiver", node->nd_recv));
|
||||||
ADD_ELEM(ret, &new_insn_body(iseq, line, BIN(methodref), 1, ID2SYM(node->nd_mid))->link);
|
ADD_ELEM(ret, &new_insn_body(iseq, line, BIN(methodref), 1, ID2SYM(node->nd_mid))->link);
|
||||||
|
if (popped) {
|
||||||
|
ADD_INSN(ret, line, pop);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNKNOWN_NODE("iseq_compile_each", node, COMPILE_NG);
|
UNKNOWN_NODE("iseq_compile_each", node, COMPILE_NG);
|
||||||
|
|
|
@ -93,6 +93,13 @@ class TestSyntax < Test::Unit::TestCase
|
||||||
assert_valid_syntax("tap (proc do end)", __FILE__, bug9726)
|
assert_valid_syntax("tap (proc do end)", __FILE__, bug9726)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_methodref_literal
|
||||||
|
assert_separately [], <<-EOS
|
||||||
|
eval 'nil.:|;1'
|
||||||
|
1000.times{eval 'nil.:|;1'}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
def test_normal_argument
|
def test_normal_argument
|
||||||
assert_valid_syntax('def foo(x) end')
|
assert_valid_syntax('def foo(x) end')
|
||||||
assert_syntax_error('def foo(X) end', /constant/)
|
assert_syntax_error('def foo(X) end', /constant/)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue