Skip to content

Commit

Permalink
Fallback to Backtrace#path if absolute_path is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
paracycle committed Jan 30, 2025
1 parent bdb8849 commit a6c6d35
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/tapioca/runtime/reflection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,17 @@ def resolve_loc(locations)
end
return unless resolved_loc

resolved_loc_path = resolved_loc.absolute_path || resolved_loc.path

# Find the location of the last frame in this file to get the most accurate line number.
resolved_loc = locations.find { |loc| loc.absolute_path == resolved_loc.absolute_path }
resolved_loc = locations.find { |loc| loc.absolute_path == resolved_loc_path }
return unless resolved_loc

# If the last operation was a `require`, and we have no more frames,
# we are probably dealing with a C-method.
return if locations.first&.label == "require"

file = resolved_loc.absolute_path || ""
file = resolved_loc.absolute_path || resolved_loc.path || ""

SourceLocation.from_loc([file, resolved_loc.lineno])
end
Expand Down

0 comments on commit a6c6d35

Please sign in to comment.