syntect: bug/panic caused by Vue.js syntax definition
When trying to highlight Vue.js files using the same syntax file that works well in Sublime, Syntect panics:
thread '<unnamed>' panicked at 'begin <= end (13 <= 7) when slicing `<style lang="stylus" scoped>`', libcore/str/mod.rs:2098:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:511
5: std::panicking::continue_panic_fmt
at libstd/panicking.rs:426
6: rust_begin_unwind
at libstd/panicking.rs:337
7: core::panicking::panic_fmt
at libcore/panicking.rs:92
8: core::str::slice_error_fail
at libcore/str/mod.rs:0
9: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}
10: <syntect::highlighting::highlighter::HighlightIterator<'a, 'b> as core::iter::iterator::Iterator>::next
11: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
12: syntect::html::highlighted_snippet_for_string
13: <std::thread::local::LocalKey<
T>>::with
14: syntect_server::rocket_route_fn_index
15: rocket::rocket::Rocket::dispatch
16: <rocket::rocket::Rocket as hyper::server::Handler>::handle
17: <hyper::server::Worker<H>>::handle_connection
18: hyper::server::listener::spawn_with::{{closure}}
(only the bits above syntect::html::highlighted_snippet_for_string are relevant)
I believe the above is pointing to https://github.com/trishume/syntect/blob/231eafce087beac80064b902c9eadefb1d078c1f/src/highlighting/highlighter.rs#L119 as the culprit, but I haven’t investigated what would cause this.
The syntax file I am using is here: vue.sublime-syntax (tmLanguage file here)
This file produces the panic (but highlights fine in ST3 with the same syntax file): https://raw.githubusercontent.com/vuejs/vue-cli/0ba111eed859aad02156e807ef71d0052b2e7f17/packages/%40vue/cli-ui-addon-webpack/src/components/ModuleListItem.vue
This file highlights fine in both Syntect and ST3 with the same syntax file: https://raw.githubusercontent.com/vuejs/vue-cli/0ba111eed859aad02156e807ef71d0052b2e7f17/packages/%40vue/cli-ui-addon-webpack/src/components/ModuleList.vue
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 20 (8 by maintainers)
Commits related to this issue
- Vue: remove for now; see https://github.com/trishume/syntect/issues/176 — committed to slimsag/Packages by slimsag 6 years ago
I managed to create this minimal (?) example that triggers the same error:
Consider this Sublime Syntax:
and the following
test.dummyfile:This will cause syntect to panic with:
This is the content of
HighlightIteratorschangesfield:I don’t understand enough about the internals of syntect and sublime syntax definitions, but I believe this is somehow related to the negative lookahead in the
(?=(foo))regex. For some reason, this causes syntect to create the additional(0, Push(<keyword>))entry.If someone can give a hint / point me in the right direction, I can try to look into this.
A similar (the same?) bug was reported here for OCaml files. This can be reproduced with
syncatand the currentmasterof syntect:test.ml
or minimal.ml:
The stack trace is the same as above:
I have the site open sourced at https://github.com/pksunkara/pksunkara.github.io. You can easily reproduce the bug if you add
vueto the code block in this section, https://github.com/pksunkara/pksunkara.github.io/blob/develop/content/posts/complex-vuejs-app-structure.md#srccomponentshellovue.