diff --git a/prism_compile.c b/prism_compile.c index 0e65d16d2e..e8eab6ed35 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -2539,6 +2539,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co case PM_CASE_NODE: case PM_CASE_MATCH_NODE: case PM_CLASS_NODE: + case PM_DEF_NODE: case PM_DEFINED_NODE: case PM_FLOAT_NODE: case PM_HASH_NODE: diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index d3ee027ef4..98083c4368 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -252,6 +252,7 @@ module Prism assert_prism_eval("defined?(case :a; when :a; 1; else; 2; end)") assert_prism_eval("defined?(case [1, 2, 3]; in [1, 2, 3]; 4; end)") assert_prism_eval("defined?(class PrismClassA; end)") + assert_prism_eval("defined?(def prism_test_def_node; end)") end def test_GlobalVariableReadNode