Skip to content

Commit e2a3f35

Browse files
meixgmeixuguang
authored andcommitted
debugger: fix behavior of { a: 1 } in the debugger repl
fix: #46808
1 parent 70e49e2 commit e2a3f35

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/internal/debugger/inspect_repl.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,16 @@ function createRepl(inspector) {
573573
if (input === '\n') return lastCommand;
574574
// Add parentheses: exec process.title => exec("process.title");
575575
const match = RegExpPrototypeExec(/^\s*(?:exec|p)\s+([^\n]*)/, input);
576+
input = match ? match[1] : input;
577+
578+
// Add parentheses to make sure input is parsed as expression
579+
if (RegExpPrototypeExec(/^\s*{/, input) !== null &&
580+
RegExpPrototypeExec(/;\s*$/, input) === null) {
581+
input = `(${StringPrototypeTrim(input)})\n`;
582+
}
583+
576584
if (match) {
577-
lastCommand = `exec(${JSONStringify(match[1])})`;
585+
lastCommand = `exec(${JSONStringify(input)})`;
578586
} else {
579587
lastCommand = input;
580588
}

0 commit comments

Comments
 (0)