From ed9d9cee76ee941c504ccea33c70c0eb5d825813 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 18 Sep 2021 21:28:35 +0900 Subject: ast.c: AST.of checks if a given method object is defined in C [Bug #18178] --- ast.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ast.c') diff --git a/ast.c b/ast.c index 202527f53f..e1c044e24c 100644 --- a/ast.c +++ b/ast.c @@ -213,6 +213,9 @@ ast_s_of(rb_execution_context_t *ec, VALUE module, VALUE body, VALUE keep_script else { iseq = rb_method_iseq(body); } + if (!iseq) { + rb_raise(rb_eArgError, "cannot get AST for method that is not defined in Ruby"); + } if (rb_iseq_from_eval_p(iseq)) { rb_raise(rb_eArgError, "cannot get AST for method defined in eval"); } -- cgit v1.2.3