[Prism] Implement defined? for PM_INDEX_OR_WRITE_NODE

Ruby code:

```ruby
defined?([0][0] ||= 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:
eileencodes 2024-01-17 10:24:34 -05:00 коммит произвёл Aaron Patterson
Родитель ff54a8f4c7
Коммит e1bae2c693
2 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -2712,6 +2712,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co
case PM_INDEX_AND_WRITE_NODE:
case PM_INDEX_OPERATOR_WRITE_NODE:
case PM_INDEX_OR_WRITE_NODE:
case PM_INSTANCE_VARIABLE_WRITE_NODE:
case PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE:

Просмотреть файл

@ -247,6 +247,7 @@ module Prism
assert_prism_eval("defined?(Prism::CPWN = 1)")
assert_prism_eval("defined?([0][0] &&= 1)")
assert_prism_eval("defined?([0][0] += 1)")
assert_prism_eval("defined?([0][0] ||= 1)")
end
def test_GlobalVariableReadNode