Skip to content

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

@robinst

Description

@robinst

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions