diff --git a/lib/error_highlight/core_ext.rb b/lib/error_highlight/core_ext.rb index d3a4dba..78cda8a 100644 --- a/lib/error_highlight/core_ext.rb +++ b/lib/error_highlight/core_ext.rb @@ -15,6 +15,7 @@ def to_s return msg unless locs loc = locs.first + return msg unless loc begin node = RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true) opts = {} diff --git a/test/test_error_highlight.rb b/test/test_error_highlight.rb index 08036bc..d31e394 100644 --- a/test/test_error_highlight.rb +++ b/test/test_error_highlight.rb @@ -1194,4 +1194,17 @@ def test_no_final_newline end end end + + def test_simulate_funcallv_from_embedded_ruby + assert_error_message(NoMethodError, <<~END) do +undefined method `foo' for nil:NilClass + END + + nil.foo + 1 + rescue NoMethodError => exc + def exc.backtrace_locations = [] + raise + end + end + end