Skip to content

Commit f4c13b3

Browse files
committed
debugger: fix behavior of { a: 1 } in the debugger repl
fix: #46808
1 parent c4103c1 commit f4c13b3

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
@@ -575,8 +575,16 @@ function createRepl(inspector) {
575575
if (input === '\n') return lastCommand;
576576
// Add parentheses: exec process.title => exec("process.title");
577577
const match = RegExpPrototypeExec(/^\s*(?:exec|p)\s+([^\n]*)/, input);
578+
input = match ? match[1] : input;
579+
580+
// Add parentheses to make sure input is parsed as expression
581+
if (RegExpPrototypeExec(/^\s*{/, input) !== null &&
582+
RegExpPrototypeExec(/;\s*$/, input) === null) {
583+
input = `(${StringPrototypeTrim(input)})\n`;
584+
}
585+
578586
if (match) {
579-
lastCommand = `exec(${JSONStringify(match[1])})`;
587+
lastCommand = `exec(${JSONStringify(input)})`;
580588
} else {
581589
lastCommand = input;
582590
}

0 commit comments

Comments
 (0)