diff options
author | Jeremy Evans <[email protected]> | 2024-01-10 13:07:34 -0800 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2024-01-10 16:02:38 -0800 |
commit | ef751252711ca7ecabb3e4ad9214fa0d1d63608a () | |
tree | d9c62a3c8ca06c2b9c983b7b49e24ee6d849ac60 | |
parent | 25f5b83689fc6dd137d45b634a0cd6e8bd024728 (diff) |
Make defined? for op asgn expressions to constants use "assignment"
Previously, it used "expression", as that was the default. However, op asgn expressions to constants use the NODE_OP_CDECL, so recognize that node type as assignement. Fixes [Bug #20111]
-rw-r--r-- | compile.c | 1 | ||||
-rw-r--r-- | test/ruby/test_defined.rb | 12 |
2 files changed, 13 insertions, 0 deletions
@@ -5951,6 +5951,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, case NODE_IASGN: case NODE_CDECL: case NODE_CVASGN: expr_type = DEFINED_ASGN; break; } @@ -127,6 +127,18 @@ class TestDefined < Test::Unit::TestCase assert_equal nil, defined?($2) end def test_defined_literal assert_equal("nil", defined?(nil)) assert_equal("true", defined?(true)) |