Project

General

Profile

Actions

Feature #19083

closed

Add `node_id_for_backtrace_location` to ast.c

Added by eileencodes (Eileen Uchitelle) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:110513]

Description

Opening a ticket to get public comments on https://github.com/ruby/ruby/pull/6593. I worked on this with Aaron Patterson.

We want to use error highlight with eval'd code, specifically ERB templates. We're able to recover the generated code for eval'd templates and can get a parse tree for the ERB generated code, but we don't have a way to get the node id from the backtrace location. So we can't pass the right node into error highlight.

This patch gives us an API to get the node id from the backtrace location so we can find the node in the AST.

This change is needed for column info in ERB templates that Aaron worked on here https://github.com/rails/rails/pull/46171. Without this change we need to set RubyVM.keep_script_lines = true. With the changes here we should be able to remove keep_script_lines.


Files

Updated by eileencodes (Eileen Uchitelle) over 1 year ago

I've update the function name from node_id_for_location to node_id_for_backtrace_location. Also I attached the patch here.

Updated by matz (Yukihiro Matsumoto) over 1 year ago

Sounds OK. Please merge.

Matz.

Updated by mame (Yusuke Endoh) over 1 year ago

  • Status changed from Open to Closed

Thank you all! I have merged the PR at 3391c51effcd61f9a718adf59740661d99f57b5b

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0