ruby / error_highlight

The gem enhances Exception#message by adding a short explanation where the exception is raised
MIT License
150 stars 23 forks source link

Support nodes in `spot` #26

Closed eileencodes closed 1 year ago

eileencodes commented 1 year ago

Fixes a bug where spot was using the wrong local variable.

We want to use error highlight with code that has been eval'd, specifically ERB templates. We can recover the compiled source code of the ERB template but we need an API to pass the node into error highlight's spot.

Required Ruby PR: https://github.com/ruby/ruby/pull/6593

Co-authored-by: Aaron Patterson tenderlove@ruby-lang.org

mame commented 1 year ago

Thanks! Could you please guard the new test with if defined?(RubyVM::AbstractSyntaxTree.node_id_for_location) or something to prevent the failure on Ruby 3.1?

mame commented 1 year ago

Thank you!