diff options
author | eileencodes <[email protected]> | 2024-01-17 11:40:01 -0500 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-01-17 17:21:29 -0500 |
commit | db9f5fc91620b799c8829d0ca69bf72564a16e14 (patch) | |
tree | 2ee41785dfbf8df0ecec22fc46fead326f86412c | |
parent | 555af5e599772033d3073afd6b91c28dc53b3f71 (diff) |
[Prism] Implement defined? for PM_UNLESS_NODE
Ruby code:
```ruby
defined?(unless true; 1; end)
```
Instructions:
```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)>
0000 putobject "expression" ( 59)[Li]
0002 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)>
0000 putobject "expression" ( 58)[Li]
0002 leave
```
Related: ruby/prism#2188
-rw-r--r-- | prism_compile.c | 1 | ||||
-rw-r--r-- | test/ruby/test_compile_prism.rb | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c index ffabda7175..876278166b 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -2571,6 +2571,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co case PM_SOURCE_LINE_NODE: case PM_STRING_NODE: case PM_SYMBOL_NODE: + case PM_UNLESS_NODE: case PM_UNTIL_NODE: case PM_WHILE_NODE: case PM_X_STRING_NODE: diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 1f9ce84bfa..f1274fccf5 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -262,6 +262,7 @@ module Prism assert_prism_eval("defined?(class << self; end)") assert_prism_eval("defined?(while a != 1; end)") assert_prism_eval("defined?(until a == 1; end)") + assert_prism_eval("defined?(unless true; 1; end)") end def test_GlobalVariableReadNode |