diff options
author | HParker <HParker@github.com> | 2023-10-27 10:44:41 -0700 |
---|---|---|
committer | Jemma Issroff <jemmaissroff@gmail.com> | 2023-10-31 07:01:00 -0300 |
commit | d8a9245513184c1dcde94ea09d95560eab577f7e (patch) | |
tree | 0707a621c876b7eec441e50726f71c57541e0d10 | |
parent | b05a7bc512e2bb0f4d097d9cc9f1db8859323798 (diff) | |
download | ruby-d8a9245513184c1dcde94ea09d95560eab577f7e.tar.gz |
Add defined array node
-rw-r--r-- | prism_compile.c | 10 | ||||
-rw-r--r-- | test/ruby/test_compile_prism.rb | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c index a52e87ea4e..9fd388dd9e 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -1131,6 +1131,16 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co case PM_FALSE_NODE: dtype = DEFINED_FALSE; break; + case PM_ARRAY_NODE: { + pm_array_node_t *array_node = (pm_array_node_t *) node; + for (size_t index = 0; index < array_node->elements.size; index++) { + pm_compile_defined_expr0(iseq, array_node->elements.nodes[index], ret, src, popped, scope_node, dummy_line_node, lineno, true, lfinish); + if (!lfinish[1]) { + lfinish[1] = NEW_LABEL(lineno); + } + ADD_INSNL(ret, &dummy_line_node, branchunless, lfinish[1]); + } + } case PM_STRING_NODE: case PM_AND_NODE: case PM_OR_NODE: diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index a5c0ee5be3..4cb82c2bae 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -93,6 +93,7 @@ module Prism assert_prism_eval("defined? self") assert_prism_eval("defined? true") assert_prism_eval("defined? false") + assert_prism_eval("defined? [A, B, C]") assert_prism_eval("defined? 'str'") assert_prism_eval("defined? a && b") assert_prism_eval("defined? a || b") |