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

panics when passed --num-format flag #1236

Open
JackDyre opened this issue Feb 20, 2025 · 2 comments · May be fixed by #1237
Open

panics when passed --num-format flag #1236

JackDyre opened this issue Feb 20, 2025 · 2 comments · May be fixed by #1237

Comments

@JackDyre
Copy link

JackDyre commented Feb 20, 2025

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?

@JackDyre
Copy link
Author

Bisecting places start of the issue at 9627a2 / #1137

@JackDyre
Copy link
Author

After some investigation, the panic seems to not be unique to the --num-format flag, it also affects some other ones.

I should have a PR up soon.

@JackDyre JackDyre linked a pull request Feb 20, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant