Skip to content

Commit da56225

Browse files
authored
fix: catch unexpected errors from acorn-loose in REPL tokenizer
PR-URL: #4956 Reviewed-by: Athan Reines <[email protected]>
1 parent db41c3d commit da56225

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/node_modules/@stdlib/repl/lib/tokenizer.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ function tokenizer( line, context ) {
6767
var i;
6868

6969
// Parse the given line into tokens & comments...
70-
ast = parse( line, {
71-
'ecmaVersion': 'latest',
72-
'onToken': onToken,
73-
'onComment': onComment
74-
});
70+
try {
71+
ast = parse( line, {
72+
'ecmaVersion': 'latest',
73+
'onToken': onToken,
74+
'onComment': onComment
75+
});
76+
} catch ( error ) { // eslint-disable-line no-unused-vars
77+
return tokens;
78+
}
7579

7680
// Resolve variable declarations from the given line as tokens...
7781
declarations = resolveLocalScopes( ast );

0 commit comments

Comments
 (0)