From acac2b8128980b97c64b4d057acdf2ceffb0b981 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 19 Dec 2021 03:40:44 +0900 Subject: Make RubyVM::AbstractSyntaxTree.of raise for backtrace location in eval This check is needed to fix a bug of error_highlight when NameError occurred in eval'ed code. https://github.com/ruby/error_highlight/pull/16 The same check for proc/method has been already introduced since 64ac984129a7a4645efe5ac57c168ef880b479b2. --- vm_backtrace.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'vm_backtrace.c') diff --git a/vm_backtrace.c b/vm_backtrace.c index f2e9bed6ba..02c2ff4abd 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -333,20 +333,25 @@ location_node_id(rb_backtrace_location_t *loc) } #endif -void -rb_frame_info_get(VALUE obj, VALUE *path, VALUE *script_lines, int *node_id) +int +rb_get_node_id_from_frame_info(VALUE obj) { #ifdef USE_ISEQ_NODE_ID rb_backtrace_location_t *loc = location_ptr(obj); - const rb_iseq_t *iseq = location_iseq(loc); - *path = iseq ? rb_iseq_path(iseq) : Qnil; - *script_lines = iseq ? iseq->body->variable.script_lines : Qnil; - *node_id = location_node_id(loc); + return location_node_id(loc); #else - *path = Qnil; + return -1; #endif } +const rb_iseq_t * +rb_get_iseq_from_frame_info(VALUE obj) +{ + rb_backtrace_location_t *loc = location_ptr(obj); + const rb_iseq_t *iseq = location_iseq(loc); + return iseq; +} + static VALUE location_realpath(rb_backtrace_location_t *loc) { -- cgit v1.2.3