Skip to content

Commit d07cc3f

Browse files
change the stack handling in FRAME_OBJECT_TO_JSON to get better stack traces
1 parent 6752ffb commit d07cc3f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

core/vm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,12 +3405,12 @@ class Interpreter {
34053405
const Identifier *ident = f.manifestFields.begin()->second;
34063406
const auto loc = f.location;
34073407
const int indentLevel = (f.indentLevel == 0) ? 0 : f.indentLevel + 1;
3408-
// Add a call frame for the JSON conversion, used to apply depth limit.
3409-
stack.newCall(loc, obj, nullptr, 0, BindingFrame{});
3410-
stack.newFrame(FRAME_TO_JSON, loc);
3411-
stack.top().indentLevel = indentLevel;
3412-
// pushes FRAME_CALL
3408+
// pushes FRAME_CALL (note this also applies the stack depth limit)
34133409
const AST *body = objectIndex(loc, obj, ident, 0);
3410+
// Before returning from the objectIndex call, convert the result to a JSON string value.
3411+
stack.newFrame(FRAME_TO_JSON, body->location);
3412+
stack.top().indentLevel = indentLevel;
3413+
// Replace the location up the stack for better traces.
34143414
ast_ = body;
34153415
goto recurse;
34163416
} else {

0 commit comments

Comments
 (0)