Closed jeremyevans closed 2 years ago
Thank you for your report. I think I got a clue. The following code will trigger an unknown bug of error_highlight (or RubyVM::AST or something).
module Foo
Object.module_eval("::Bar", __FILE__, __LINE__)
end
The error message changes if error_highlight is enabled:
$ ruby --disable-error_highlight t.rb
t.rb:2:in `<module:Foo>': uninitialized constant Bar (NameError)
from t.rb:2:in `module_eval'
from t.rb:2:in `<module:Foo>'
from t.rb:1:in `<main>'
$ ruby t.rb
t.rb:2:in `<module:Foo>': NameError
from t.rb:2:in `module_eval'
from t.rb:2:in `<module:Foo>'
from t.rb:1:in `<main>'
I'll continue to investigate the issue tonight
@jeremyevans I think the issue was fixed by the combination of https://github.com/ruby/error_highlight/commit/d2140d795ad0a06398db81739201877d431755db and https://github.com/ruby/ruby/commit/6a51c3e80c0901851c252ed4d1387e43939a452f. Could you try ruby/ruby master with your code base? Let me know if it is not fixed yet.
Ah, no, the issue is not fixed yet. Continue to investigate...
Argh, a pilot error. I used the older ruby to check if the issue is fixed or not. I think it's fixed after all.
I've built and installed ruby-head locally and checked and confirmed the problem is fixed. Thank you very much for fixing this!
This fixes an issue in Sequel's tests on ruby 3.1.0-preview1, where a test was showing the wrong output in an exception message. The related code rescues NameError to provide more information, then reraises. Here's the output of Sequel's test without changes to error_highlight:
This change makes the Sequel test pass. There probably is a better fix.
I tried to reproduce this outside of Sequel's tests in order to create a test for error_highlight, but I wasn't able to do so quickly.