Implement paren node for defined?

Implements and adds a test for passing a parentheses node to `defined?`.
This commit is contained in:
eileencodes 2023-12-01 14:52:38 -05:00 committed by Aaron Patterson
parent 6ecc1ca9b1
commit 818813c2bd
2 changed files with 4 additions and 2 deletions

View File

@ -1442,10 +1442,10 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co
// in_condition is the same as compile.c's needstr
enum defined_type dtype = DEFINED_NOT_DEFINED;
switch (PM_NODE_TYPE(node)) {
case PM_NIL_NODE: {
case PM_NIL_NODE:
case PM_PARENTHESES_NODE:
dtype = DEFINED_NIL;
break;
}
case PM_SELF_NODE:
dtype = DEFINED_SELF;
break;

View File

@ -150,6 +150,8 @@ module Prism
assert_prism_eval("x = 1; defined? x ||= 1")
assert_prism_eval("if defined? A; end")
assert_prism_eval("defined?(())")
end
def test_GlobalVariableReadNode