зеркало из https://github.com/github/ruby.git
[Prism] Implement defined? for PM_CALL_AND_WRITE_NODE
Ruby code: ```ruby defined?(PrismTestSubclass.test_call_and_write_node &&= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
This commit is contained in:
Родитель
a6e924cf5f
Коммит
f657fd150f
|
@ -2686,6 +2686,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co
|
|||
ADD_INSN3(ret, &dummy_line_node, defined, INT2FIX(DEFINED_ZSUPER), 0,
|
||||
PUSH_VAL(DEFINED_ZSUPER));
|
||||
return;
|
||||
case PM_CALL_AND_WRITE_NODE:
|
||||
case PM_CONSTANT_WRITE_NODE:
|
||||
case PM_CONSTANT_OPERATOR_WRITE_NODE:
|
||||
case PM_CONSTANT_AND_WRITE_NODE:
|
||||
|
|
|
@ -237,6 +237,8 @@ module Prism
|
|||
assert_prism_eval("defined?(defined?(a))")
|
||||
assert_prism_eval('defined?(:"#{1}")')
|
||||
assert_prism_eval("defined?(`echo #{1}`)")
|
||||
|
||||
assert_prism_eval("defined?(PrismTestSubclass.test_call_and_write_node &&= 1)")
|
||||
end
|
||||
|
||||
def test_GlobalVariableReadNode
|
||||
|
|
Загрузка…
Ссылка в новой задаче