From 1ac3c7aa6e643a8e523218e1df438bb72bbaf920 Mon Sep 17 00:00:00 2001 From: Snehil Shah Date: Wed, 29 Jan 2025 18:53:27 +0000 Subject: [PATCH] fix: catch unexpected errors from `acorn-loose` in REPL tokenizer Signed-off-by: Snehil Shah --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/repl/lib/tokenizer.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/repl/lib/tokenizer.js b/lib/node_modules/@stdlib/repl/lib/tokenizer.js index 825aba460bbd..1e12be64ce6e 100644 --- a/lib/node_modules/@stdlib/repl/lib/tokenizer.js +++ b/lib/node_modules/@stdlib/repl/lib/tokenizer.js @@ -67,11 +67,15 @@ function tokenizer( line, context ) { var i; // Parse the given line into tokens & comments... - ast = parse( line, { - 'ecmaVersion': 'latest', - 'onToken': onToken, - 'onComment': onComment - }); + try { + ast = parse( line, { + 'ecmaVersion': 'latest', + 'onToken': onToken, + 'onComment': onComment + }); + } catch ( error ) { // eslint-disable-line no-unused-vars + return tokens; + } // Resolve variable declarations from the given line as tokens... declarations = resolveLocalScopes( ast );