Skip to content

Commit 774b28f

Browse files
mscdexbnoordhuis
authored andcommitted
repl: fix JSON.parse error check
Before this, entering something like: > JSON.parse('066'); resulted in the "..." prompt instead of displaying the expected "SyntaxError: Unexpected number"
1 parent 9ee86b7 commit 774b28f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/repl.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,5 @@ function isSyntaxError(e) {
923923
// "strict mode" syntax errors
924924
!e.match(/^SyntaxError: .*strict mode.*/i) &&
925925
// JSON.parse() error
926-
!(e.match(/^SyntaxError: Unexpected (token .*|end of input)/) &&
927-
e.match(/\n {4}at Object.parse \(native\)\n/));
926+
!e.match(/\n {4}at Object.parse \(native\)\n/);
928927
}

test/simple/test-repl.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ function error_test() {
134134
expect: /^SyntaxError: Unexpected token i/ },
135135
// end of input to JSON.parse error is special case of syntax error,
136136
// should throw
137+
{ client: client_unix, send: 'JSON.parse(\'066\');',
138+
expect: /^SyntaxError: Unexpected number/ },
139+
// should throw
137140
{ client: client_unix, send: 'JSON.parse(\'{\');',
138141
expect: /^SyntaxError: Unexpected end of input/ },
139142
// invalid RegExps are a special case of syntax error,

0 commit comments

Comments
 (0)