Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread main panicked on Result::unwrap() with simple js file #60

Closed
reklis opened this issue May 5, 2018 · 2 comments
Closed

thread main panicked on Result::unwrap() with simple js file #60

reklis opened this issue May 5, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@reklis
Copy link

reklis commented May 5, 2018

> cat index2.js
const io

> bat index2.js
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: 
Error(-114, target of repeat operator is invalid)', libcore/result.rs:945:5

This appears to be syntax related, if I change the file name to .py it works

> mv index2.js index2.py

> bat index2.py
───────┬────────────────────────────────────────────────────────────────────
       │ File index2.py
───────┼────────────────────────────────────────────────────────────────────
   1   │ const io
───────┴────────────────────────────────────────────────────────────────────

I'm using the sample from the readme for the syntax definitions

mkdir -p ~/.config/bat/syntax
cd ~/.config/bat/syntax

# Download some language definition files, for example:
git clone https://github.com/sublimehq/Packages/
rm -rf Packages/Markdown
git clone https://github.com/jonschlinkert/sublime-markdown-extended
@sharkdp
Copy link
Owner

sharkdp commented May 5, 2018

Yes, this is related to the JavaScript.sublime-syntax file in https://github.com/sublimehq/Packages/ which contains a regular expression that syntect can not parse. I have already addressed this upstream (trishume/syntect#156) and opened a pull request to fix this in sublimehq/Packages (sublimehq/Packages#1525).

bat currently ships with a manually-patched version of the JavaScript syntax:

diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax
index 93a478f..8ebb1d0 100644
--- a/JavaScript/JavaScript.sublime-syntax
+++ b/JavaScript/JavaScript.sublime-syntax
@@ -15,7 +15,7 @@ variables:
   identifier: '{{identifier_start}}{{identifier_part}}*{{identifier_break}}'
   constant_identifier: '[[:upper:]]{{identifier_part}}*{{identifier_break}}'
   dollar_only_identifier: '\${{identifier_break}}'
-  dollar_identifier: '(\$){{identifier_part}}*{{identifier_break}}+'
+  dollar_identifier: '(\$){{identifier_part}}*{{identifier_break}}'
   func_lookahead: '\s*(async\s+)?function{{identifier_break}}'
   arrow_func_lookahead: '\s*(async\s*)?({{identifier}}|\(([^()]|\([^()]*\))*\))\s*=>'
   either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}})

@sharkdp sharkdp added the bug Something isn't working label May 6, 2018
@sharkdp
Copy link
Owner

sharkdp commented May 7, 2018

This should be fixed, my upstream PR has been merged.

@sharkdp sharkdp closed this as completed May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants