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

bat panics on Ruby files with unindented heredocs #914

Closed
sharkdp opened this issue Apr 12, 2020 · 4 comments
Closed

bat panics on Ruby files with unindented heredocs #914

sharkdp opened this issue Apr 12, 2020 · 4 comments
Labels
bug Something isn't working syntax-highlighting upstream-error A bug in an upstream component
Milestone

Comments

@sharkdp
Copy link
Owner

sharkdp commented Apr 12, 2020

When calling bat on this Ruby file

<<END_DESC
Test
END_DESC

it panics with:

thread 'main' panicked at
  'regex string should be pre-tested: Error(-208, invalid backref number/name)',
  …/syntect-4.1.0/src/parsing/regex.rs:70:17

found with the Python script in #913.

@sharkdp sharkdp added bug Something isn't working syntax-highlighting upstream-error A bug in an upstream component labels Apr 12, 2020
@sharkdp
Copy link
Owner Author

sharkdp commented Apr 12, 2020

This is caused by the block here: https://github.com/sublimehq/Packages/blob/f36b8f807d5f30d2b8ef639232a9fc5960f550fa/Ruby/Ruby.sublime-syntax#L1914-L1917

  unindented-heredoc-end:
    - match: ^\1$ # HEREDOC delimiter
      scope: string.unquoted.heredoc.ruby punctuation.definition.string.end.ruby
      pop: true

This block seems to reference the heredoc name from the opening part

  heredoc-ruby:
    - match: <<[-~]["`]?({{heredoc_type_ruby}})["`]?
      scope: string.unquoted.heredoc.ruby punctuation.definition.string.begin.ruby
      push: [heredoc-ruby-indented-interpolated, trailing-heredoc-start]
    - match: <<[-~]'({{heredoc_type_ruby}})'
      scope: string.unquoted.heredoc.ruby punctuation.definition.string.begin.ruby
      push: [heredoc-ruby-indented-literal, trailing-heredoc-start]
    - match: <<["`]?({{heredoc_type_ruby}})["`]?
      scope: string.unquoted.heredoc.ruby punctuation.definition.string.begin.ruby
      push: [heredoc-ruby-unindented-interpolated, trailing-heredoc-start]
    - match: <<'({{heredoc_type_ruby}})'
      scope: string.unquoted.heredoc.ruby punctuation.definition.string.begin.ruby
      push: [heredoc-ruby-unindented-literal, trailing-heredoc-start]

but for some reason, the \1 reference can not be resolved.

@keith-hall
Copy link
Collaborator

this looks like an instance of trishume/syntect#104 to me

@sharkdp
Copy link
Owner Author

sharkdp commented Apr 13, 2020

Certainly seems like it - thank you for the reference!

@sharkdp
Copy link
Owner Author

sharkdp commented Apr 21, 2020

closed via #929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working syntax-highlighting upstream-error A bug in an upstream component
Projects
None yet
Development

No branches or pull requests

2 participants