parent
b003d40194
commit
adaaa7878e
Notes:
git
2025-03-18 18:44:49 +00:00
@ -4213,7 +4213,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_l
|
||||
// If we have empty parentheses, then we want to return "nil".
|
||||
dtype = DEFINED_NIL;
|
||||
}
|
||||
else if (PM_NODE_TYPE_P(cast->body, PM_STATEMENTS_NODE) && ((const pm_statements_node_t *) cast->body)->body.size == 1) {
|
||||
else if (PM_NODE_TYPE_P(cast->body, PM_STATEMENTS_NODE) && !PM_NODE_FLAG_P(cast, PM_PARENTHESES_NODE_FLAGS_MULTIPLE_STATEMENTS)) {
|
||||
// If we have a parentheses node that is wrapping a single statement
|
||||
// then we want to recurse down to that statement and compile it.
|
||||
pm_compile_defined_expr0(iseq, ((const pm_statements_node_t *) cast->body)->body.nodes[0], node_location, ret, popped, scope_node, in_condition, lfinish, false);
|
||||
|
1
test/.excludes-parsey/TestDefined.rb
Normal file
1
test/.excludes-parsey/TestDefined.rb
Normal file
@ -0,0 +1 @@
|
||||
exclude(:test_defined_paren_void_stmts, "defined? (x;)")
|
@ -243,6 +243,26 @@ class TestDefined < Test::Unit::TestCase
|
||||
assert_nil(defined?(p () + 1))
|
||||
end
|
||||
|
||||
def test_defined_paren_void_stmts
|
||||
assert_equal("expression", defined? (;x))
|
||||
assert_equal("expression", defined? (x;))
|
||||
assert_nil(defined? (
|
||||
|
||||
x
|
||||
|
||||
))
|
||||
|
||||
x = 1
|
||||
|
||||
assert_equal("expression", defined? (;x))
|
||||
assert_equal("expression", defined? (x;))
|
||||
assert_equal("local-variable", defined? (
|
||||
|
||||
x
|
||||
|
||||
))
|
||||
end
|
||||
|
||||
def test_defined_impl_specific
|
||||
feature7035 = '[ruby-core:47558]' # not spec
|
||||
assert_predicate(defined?(Foo), :frozen?, feature7035)
|
||||
|
Loading…
x
Reference in New Issue
Block a user