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

Pluralisation fails for infinite values #701

Closed
eliocamp opened this issue Jul 4, 2024 · 1 comment
Closed

Pluralisation fails for infinite values #701

eliocamp opened this issue Jul 4, 2024 · 1 comment
Labels
bug an unexpected problem or unintended behavior tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@eliocamp
Copy link

eliocamp commented Jul 4, 2024

If the number used for pluralisation is Inf, message creation fails.

errormsg <- "{n_out} file{?s} expected"

n_out <- 1
cli::cli_text(errormsg)
#> 1 file expected

n_out <- 2
cli::cli_text(errormsg)
#> 2 files expected

n_out <- Inf
cli::cli_text(errormsg)
#> Warning in make_quantity(values$qty): NAs introduced by coercion to integer
#> range
#> Warning in make_quantity(values$qty): NAs introduced by coercion to integer
#> range
#> Error in if (qty != 1) parts[1] else "": missing value where TRUE/FALSE needed

The issue I think starts here, where the number is coerced to an integer. as.integer(Inf) is NA. Then here process_plural() runs if (length(parts) == 1), which is NA.

I'm not sure there's a standard way of pluralising infinite value, so the solution might be to catch the issue early and throw a better error instead of implementing plurals for Inf.

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Jul 4, 2024
@gaborcsardi gaborcsardi added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jul 17, 2024
@gaborcsardi
Copy link
Member

Closed by #716.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

No branches or pull requests

2 participants