зеркало из https://github.com/github/ruby.git
[Bug #19966] [PRISM] Fix singleton method definition
This commit is contained in:
Родитель
84dfa0fa5e
Коммит
9d1940ba3c
|
@ -1346,7 +1346,13 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||
pm_scope_node_init((pm_node_t *)def_node, &next_scope_node, scope_node, parser);
|
||||
rb_iseq_t *method_iseq = NEW_ISEQ(next_scope_node, rb_id2str(method_name), ISEQ_TYPE_METHOD, lineno);
|
||||
|
||||
ADD_INSN2(ret, &dummy_line_node, definemethod, ID2SYM(method_name), method_iseq);
|
||||
if (def_node->receiver) {
|
||||
pm_compile_node(iseq, def_node->receiver, ret, src, false, scope_node);
|
||||
ADD_INSN2(ret, &dummy_line_node, definesmethod, ID2SYM(method_name), method_iseq);
|
||||
}
|
||||
else {
|
||||
ADD_INSN2(ret, &dummy_line_node, definemethod, ID2SYM(method_name), method_iseq);
|
||||
}
|
||||
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)method_iseq);
|
||||
|
||||
if (!popped) {
|
||||
|
|
|
@ -409,6 +409,11 @@ module Prism
|
|||
test_prism_eval("alias :prism_a :to_s")
|
||||
end
|
||||
|
||||
def test_DefNode
|
||||
test_prism_eval("def prism_method; end")
|
||||
test_prism_eval("a = Object.new; def a.prism_singleton; :ok; end; a.prism_singleton")
|
||||
end
|
||||
|
||||
def test_UndefNode
|
||||
test_prism_eval("def prism_undef_node_1; end; undef prism_undef_node_1")
|
||||
test_prism_eval(<<-HERE
|
||||
|
|
Загрузка…
Ссылка в новой задаче