Skip to content

Commit b21df3b

Browse files
committed
Only use an adopted node for BacktraceFormatter.printableRubyBacktrace()
1 parent c3464fa commit b21df3b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/org/truffleruby/language/backtrace/BacktraceFormatter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static BacktraceFormatter createDefaultFormatter(RubyContext context, Rub
6969
// For debugging:
7070
// org.truffleruby.language.backtrace.BacktraceFormatter.printableRubyBacktrace(this)
7171
public static String printableRubyBacktrace(Object maybeNode) {
72-
final Node node = maybeNode instanceof Node ? (Node) maybeNode : null;
72+
final Node node = maybeNode instanceof Node n && n.isAdoptable() ? (Node) maybeNode : null;
7373
final RubyContext context = RubyLanguage.getCurrentContext();
7474
final BacktraceFormatter backtraceFormatter = new BacktraceFormatter(
7575
context,
@@ -79,7 +79,7 @@ public static String printableRubyBacktrace(Object maybeNode) {
7979
if (backtrace.isEmpty()) {
8080
return "<empty backtrace>";
8181
} else if (node == null) {
82-
return "# the first entry line is imprecise because 'this' is not a Node, select caller Java frames in the debugger until 'this' is a Node to fix this\n" +
82+
return "# the first entry line is imprecise because 'this' is not an adopted Node, select caller Java frames in the debugger until 'this' is an adopted Node to fix this\n" +
8383
backtrace;
8484
} else {
8585
return backtrace;

0 commit comments

Comments
 (0)