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

fix: parse "infinity" literal fully in float #1673

Merged
merged 3 commits into from
Oct 21, 2023
Merged

Conversation

boxdot
Copy link
Contributor

@boxdot boxdot commented Jun 29, 2023

float first parsed the "inf" literal and then "infinity", therefore even though the latter was parsed correctly, the suffix "inity" was returned as remaining input, which is not correct.

`float` first parsed the "inf" literal and then "infinity", therefore
even though the latter was parsed correctly, the suffix "inity" was
returned as remaining input, which is not correct.
@boxdot boxdot requested a review from Geal as a code owner June 29, 2023 08:47
@epage
Copy link
Contributor

epage commented Jun 29, 2023

Not the maintainer but I'm assuming the intent here is to parse the keywords inf, similar to nan. infinity isn't generally a keyword. The reason inity is being left is because nom-style parsers leave all unrecognized content for the next parser to identify or error on.

For a language when an invalid keyword is used often enough, it can make sense to special case the error situation into the grammar (match on infinity but error).

@boxdot
Copy link
Contributor Author

boxdot commented Jun 29, 2023

infinity isn't generally a keyword

I forgot to mention that nom 6 parsed infinity as float infinity without remaining input. The current code also contains a case and tests for parsing infinity completely. So, I assume it is a regression in nom 7.

My motivation is actually this upgrade: garvys-org/rustfst#240

@epage
Copy link
Contributor

epage commented Jun 29, 2023

Huh, didn't realize that FromStr accepts infinity. FromStr and lexical_core were the nom v6 implementations of float. In nom v7, an attempt was made to switch to minimal_lexical (baf5e01) but that had problems (f8633f9). Whats confusing is I'm not seeing how the minimal_lexical version was meant to handle nan, inf, and infinity.

epage added a commit to epage/winnow that referenced this pull request Jun 29, 2023
epage added a commit to epage/winnow that referenced this pull request Jun 29, 2023
epage added a commit to epage/winnow that referenced this pull request Jul 6, 2023
@Geal
Copy link
Collaborator

Geal commented Oct 21, 2023

right, the order was wrong here, nice catch

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6597520943

  • 4 of 6 (66.67%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 62.41%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/number/mod.rs 0 2 0.0%
Totals Coverage Status
Change from base Build 6597500402: 0.0%
Covered Lines: 1828
Relevant Lines: 2929

💛 - Coveralls

@Geal Geal merged commit 63def4e into rust-bakery:main Oct 21, 2023
14 checks passed
@Geal
Copy link
Collaborator

Geal commented Oct 21, 2023

thank you!

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 this pull request may close these issues.

4 participants