From 3a58009066049f9af09ea3171cecab88ba0d9f1c Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 10 Aug 2022 21:17:04 +0900 Subject: [ruby/error_highlight] Make backtrace_location keyword work We had to keep backtrace_location before opts is overwritten. https://github.com/ruby/error_highlight/commit/2735e4681a --- lib/error_highlight/base.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/error_highlight') diff --git a/lib/error_highlight/base.rb b/lib/error_highlight/base.rb index 51f1ce369d..dbd173a5cd 100644 --- a/lib/error_highlight/base.rb +++ b/lib/error_highlight/base.rb @@ -26,9 +26,9 @@ module ErrorHighlight case obj when Exception exc = obj + loc = opts[:backtrace_location] opts = { point_type: opts.fetch(:point_type, :name) } - loc = opts[:backtrace_location] unless loc case exc when TypeError, ArgumentError @@ -44,6 +44,8 @@ module ErrorHighlight opts[:name] = exc.name if NameError === obj end + return nil unless Thread::Backtrace::Location === loc + node = RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true) Spotter.new(node, **opts).spot -- cgit v1.2.3