Skip to content

Commit 2f47ccc

Browse files
change the stack handling in FRAME_OBJECT_TO_JSON to get better stack traces
1 parent cbec079 commit 2f47ccc

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
@@ -3318,12 +3318,12 @@ class Interpreter {
33183318
const Identifier *ident = f.manifestFields.begin()->second;
33193319
const auto loc = f.location;
33203320
const int indentLevel = (f.indentLevel == 0) ? 0 : f.indentLevel + 1;
3321-
// Add a call frame for the JSON conversion, used to apply depth limit.
3322-
stack.newCall(loc, obj, nullptr, 0, BindingFrame{});
3323-
stack.newFrame(FRAME_TO_JSON, loc);
3324-
stack.top().indentLevel = indentLevel;
3325-
// pushes FRAME_CALL
3321+
// pushes FRAME_CALL (note this also applies the stack depth limit)
33263322
const AST *body = objectIndex(loc, obj, ident, 0);
3323+
// Before returning from the objectIndex call, convert the result to a JSON string value.
3324+
stack.newFrame(FRAME_TO_JSON, body->location);
3325+
stack.top().indentLevel = indentLevel;
3326+
// Replace the location up the stack for better traces.
33273327
ast_ = body;
33283328
goto recurse;
33293329
} else {

0 commit comments

Comments
 (0)