Feature #19083
closedAdd `node_id_for_backtrace_location` to ast.c
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 2 years ago
- File 0001-Add-node_id_for_backtrace_location-function.patch 0001-Add-node_id_for_backtrace_location-function.patch added
- Subject changed from Add `node_id_for_location` to ast.c to Add `node_id_for_backtrace_location` to ast.c
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 2 years ago
Sounds OK. Please merge.
Matz.
Updated by mame (Yusuke Endoh) over 2 years ago
- Status changed from Open to Closed
Thank you all! I have merged the PR at 3391c51effcd61f9a718adf59740661d99f57b5b