Skip to content

Commit

Permalink
Merge pull request #458 from yuuu/use_binding_source_location
Browse files Browse the repository at this point in the history
Fix warning: __FILE__ in eval may not return location in binding
  • Loading branch information
RobinDaugherty committed Apr 18, 2020
2 parents 4142e39 + dbe7ca0 commit c993df6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/better_errors/raised_exception.rb
Expand Up @@ -35,8 +35,13 @@ def setup_backtrace

def setup_backtrace_from_bindings
@backtrace = exception.__better_errors_bindings_stack.map { |binding|
file = binding.eval "__FILE__"
line = binding.eval "__LINE__"
if binding.respond_to?(:source_location) # Ruby >= 2.6
file = binding.source_location[0]
line = binding.source_location[1]
else
file = binding.eval "__FILE__"
line = binding.eval "__LINE__"
end
name = binding.frame_description
StackFrame.new(file, line, name, binding)
}
Expand Down

0 comments on commit c993df6

Please sign in to comment.