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

Panic: Can only iterate patterns after linking: Named("types") with C# file #37

Closed
robinst opened this issue Mar 6, 2017 · 3 comments
Closed

Comments

@robinst
Copy link
Collaborator

robinst commented Mar 6, 2017

Reproduce on master with 1748efe:

$ cat bug.cs
public class Foo
{
    private static void Bar()
    {
        baz.Sort((a, b) => b.depth.CompareTo(a.depth));
    }
}
$ cargo build --example synstats && RUST_BACKTRACE=1 ./target/debug/examples/synstats bug.cs

Output:

################## Files ###################
bug.cs
thread 'main' panicked at 'Can only iterate patterns after linking: Named("types")', src/parsing/syntax_definition.rs:137
stack backtrace:
   1:        0x105c130ea - std::sys::imp::backtrace::tracing::imp::write::hd3b65cdfe843284c
   2:        0x105c14e8f - std::panicking::default_hook::{{closure}}::hf2b7428652613d83
   3:        0x105c14b37 - std::panicking::default_hook::h5da8f27db5582938
   4:        0x105c152f6 - std::panicking::rust_panic_with_hook::hcef1e67c646c6802
   5:        0x105c15194 - std::panicking::begin_panic::hc2e8ca89533cd10d
   6:        0x105c150b2 - std::panicking::begin_panic_fmt::h60990696c3c3a88d
   7:        0x105bd40e8 - <syntect::parsing::syntax_definition::MatchIter as core::iter::iterator::Iterator>::next::h0fc92fde02d6dd7f
   8:        0x105bdc6ea - syntect::parsing::parser::ParseState::parse_next_token::h7b5d8225fe16d480
   9:        0x105bdbf28 - syntect::parsing::parser::ParseState::parse_line::hde79bb6ed3c527e5
  10:        0x105b66cbd - synstats::count::h5c86d3300a80813b
  11:        0x105b6739e - synstats::main::h761e13430343e881
  12:        0x105c160ea - __rust_maybe_catch_panic
  13:        0x105c15696 - std::rt::lang_start::h87cb84a8b6cb187e
  14:        0x105b67839 - main

The Sort line is the problematic one. The original file had a lot more code in it, but removing that line makes it work.

@trishume
Copy link
Owner

trishume commented Mar 6, 2017

Darn. I think the C# syntax at some point says to push a "types" scope which doesn't exist, and I don't handle that case properly so it panics. It should just silently do its best because syntax highlighting shouldn't crash.

There's one other scenario I know of where a bad syntax can cause a crash at highlighting-time (malformed regexes) that I also haven't handled properly.

@keith-hall
Copy link
Collaborator

keith-hall commented Mar 7, 2017

I believe it was an include, rather than a push, and ST just ignores includes if it can't find them (and logs a warning to it's console). Pushes (and sets) to invalid contexts, on the other hand, should always fail as it is an error in the syntax def. Meanwhile, you can use the latest version of the syntax definition from the SublimeHQ's Packages repo's master branch to highlight your C# code, where the missing include has been removed.

@trishume
Copy link
Owner

trishume commented Apr 5, 2017

I just pushed v1.3.0 to crates.io with the fix for this. Release notes are on the Github releases page.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants