Skip to content

panics when passed --num-format flag #1236

@JackDyre

Description

@JackDyre

Parsing the --num-format flag causes a panic.


Steps to reproduce

  • >= tokei 13.0.0-alpha.8
  • pass the --num-format or -n flag

All 4 possible values for the flag cause the same result.

I was able to reproduce this using both the AUR tokei-git package on tokei 13.0.0-alpha.8 and cloning the running the latest source from github. The stable 12.1.2 on nixpkgs did not have this issue.

Interestingly they had different panic messages.

Source code code from github (debug profile):

   ~/../../tokei ❯ ./target/debug/tokei ../../ninja -n dots
thread 'main' panicked at src/cli.rs:259:14:
Mismatch between definition and access of `num_format_style`. Could not downcast to tokei::cli_utils::NumberFormatStyle, need to downcast to alloc::string::String

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Release profile (both github src code and aur tokei-git package):

   ~/../../tokei ❯ tokei ../../ninja -n dots
thread 'main' panicked at /home/riley/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.15/src/parser/error.rs:32:9:
Mismatch between definition and access of `num_format_style`. Could not downcast to TypeId(0x87f994611b2542ce423a2635f1af69ff), need to downcast to TypeId(0xe66dcd7c1cbd9c1c240a693be4ce9ff4)

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
zsh: IOT instruction (core dumped)  tokei ../../ninja -n dots

Notably one places the panic in-crate and the other places the panic in an external crate.


Relevant code snippet:

        // src/cli.rs:258-261
        let num_format_style: NumberFormatStyle = matches
            .get_one::<NumberFormatStyle>("num_format_style") // Panic line (according to debug build)
            .cloned()
            .unwrap_or_default();

I will bisect when I get a chance. Bad commit is on the version range (12.1.2, 13.0.0-alpha.8)

In the meantime, is anyone else able to reproduce?

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