зеркало из https://github.com/github/ruby.git
Add error for iseqs compiled by prism
This commit is contained in:
Родитель
0f1ca9492c
Коммит
82a4c3af16
5
ast.c
5
ast.c
|
@ -253,6 +253,11 @@ ast_s_of(rb_execution_context_t *ec, VALUE module, VALUE body, VALUE keep_script
|
|||
if (!iseq) {
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
if (ISEQ_BODY(iseq)->prism) {
|
||||
rb_raise(rb_eRuntimeError, "cannot get AST for ISEQ compiled by prism");
|
||||
}
|
||||
|
||||
lines = ISEQ_BODY(iseq)->variable.script_lines;
|
||||
|
||||
VALUE path = rb_iseq_path(iseq);
|
||||
|
|
|
@ -54,7 +54,16 @@ module ErrorHighlight
|
|||
|
||||
return nil unless Thread::Backtrace::Location === loc
|
||||
|
||||
node = RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true)
|
||||
node =
|
||||
begin
|
||||
RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true)
|
||||
rescue RuntimeError => error
|
||||
# RubyVM::AbstractSyntaxTree.of raises an error with a message that
|
||||
# includes "prism" when the ISEQ was compiled with the prism compiler.
|
||||
# In this case, we'll set the node to `nil`. In the future, we will
|
||||
# reparse with the prism parser and pass the parsed node to Spotter.
|
||||
raise unless error.message.include?("prism")
|
||||
end
|
||||
|
||||
Spotter.new(node, **opts).spot
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче