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

[BUG] consecutive_digit_separator has no effect #96

Closed
dubrowgn opened this issue May 29, 2023 · 1 comment · Fixed by #161
Closed

[BUG] consecutive_digit_separator has no effect #96

dubrowgn opened this issue May 29, 2023 · 1 comment · Fixed by #161
Assignees
Labels
bug Something isn't working normal priority Normal Priority
Milestone

Comments

@dubrowgn
Copy link

dubrowgn commented May 29, 2023

Description

First, thanks for the great library!

Perhaps I am doing this wrong, or misunderstanding what the flag is supposed to do, but it appears that consecutive_digit_separator has no effect on the results of parsing. Setting it to false still allows multiple consecutive digit separators in the source string.

Prerequisites

  • Rust version: rustc 1.68.0 (2c8cc3432 2023-03-06)
  • lexical version:
    lexical-util v0.8.5
    lexical-parse-integer v0.8.6
    lexical-parse-float v0.8.5
    lexical-core v0.8.5
    lexical v6.1.1
  • Cargo.toml
[dependencies.lexical]
default-features = false
features = [ "parse-floats", "parse-integers" ]
version = "6.x"

[dependencies.lexical-parse-integer]
default-features = false
features = [ "format", "power-of-two" ]
version = "x"

[dependencies.lexical-parse-float]
default-features = false
features = [ "format", "power-of-two" ]
version = "x"

Test case

let opts = lexical_parse_float::Options::new();
const FMT: u128 = NumberFormatBuilder::new()
	.digit_separator(num::NonZeroU8::new(b'_'))
	.leading_digit_separator(true)
	.internal_digit_separator(true)
	.trailing_digit_separator(true)
	.consecutive_digit_separator(false)
	.build();
println!("{:?}", lexical::parse_with_options::<f64, _, FMT>("__1__234__", &opts));

// Ok(1234.0)
@Alexhuszagh
Copy link
Owner

Alexhuszagh commented Sep 20, 2024

Confirmed this affects both integer and floating point parsing, it seems like this corner case was never tested in our API tests, only the positive case. It seems there's something wrong with the peek_1! macro.

Alexhuszagh added a commit that referenced this issue Sep 22, 2024
This addressed #96 and #97, fixing the lack of processing with
consecutive digit separators by enhancing the internal logic, adds logic
for internal and first digit separators to simplify logic and improve
performance, fix unittests, and also make it so the errors are
consistent by adding checks when formatting is enabled to ensure the
correct logic is used.

Closes #96
Closes #97
Alexhuszagh added a commit that referenced this issue Sep 24, 2024
This addressed #96 and #97, fixing the lack of processing with
consecutive digit separators by enhancing the internal logic, adds logic
for internal and first digit separators to simplify logic and improve
performance, fix unittests, and also make it so the errors are
consistent by adding checks when formatting is enabled to ensure the
correct logic is used.

Closes #96
Closes #97
Alexhuszagh added a commit that referenced this issue Sep 24, 2024
This addressed #96 and #97, fixing the lack of processing with
consecutive digit separators by enhancing the internal logic, adds logic
for internal and first digit separators to simplify logic and improve
performance, fix unittests, and also make it so the errors are
consistent by adding checks when formatting is enabled to ensure the
correct logic is used.

Closes #96
Closes #97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working normal priority Normal Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants