-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Configuration
ruby 3.3.3
Steps to Reproduce
Run the following script error_script.rb:
begin
x = nil
x += 5
rescue StandardError => exception
pp ErrorHighlight.spot(exception, backtrace_location: exception.backtrace_locations[0])
end
using
ruby error_script.rb
Expected Results
My reading of the comment in the header above the ErrorHighlight::spot
method is that if its return value is not nil, it should be a hash containing, among other things, integer values corresponding to the :first_lineno
and :last_lineno
keys.
Actual Results
ErrorHighlight::spot
returns a hash in which the values corresponding to the :first_lineno
and :last_lineno
keys are nil.
Analysis
The above program eventually finds itself in the last elsif
clause of ErrorHighlight::Spotter#spot_call_for_name
. That clause doesn't set the @beg_lineno
and @end_lineno
instance variables, whereas all the other clauses in that statement do. Eventually these variable values find their way into the return value of ErrorHighlight::Spotter#spot
as nils.
I noticed it because it causes rails exception reporting code to malfunction in certain circumstances. #54384