`pluralize` fails for values outside ±`.Machine$integer.max`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
Research direction
Start by locating the pluralize implementation and its make_quantity path, which is named in the warning. Reproduce the reported positive and negative boundary cases, then verify that quantities outside R's integer range remain comparable and pluralize completes without an NA-related error.
Written by the indexing model from the issue text.
Description
When trying to compare integers (but not doubles) outside of ±.Machine$integer.max, R returns NA, causing pluralize to fail, as qty != 1 cannot be properly evaluated.
# This works
(.Machine$integer.max + 1) != 1
#> [1] TRUE
# ...but this does not
as.integer(.Machine$integer.max + 1) != 1
#> Warning: NAs introduced by coercion to integer range
#> [1] NA
pluralize reprex
cli::pluralize("{99} bug{?s} in the code")
#> 99 bugs in the code
n_bugs <- 99
cli::pluralize("{n_bugs} bug{?s} in the code")
#> 99 bugs in the code
cli::cli_inform(c("Take one down",
"And patch it up",
"You got"))
#> Take one down
#> And patch it up
#> You got
n_bugs <- .Machine$integer.max
cli::pluralize("{n_bugs} bug{?s}")
#> 2147483647 bugs
cli::pluralize("...add one more and it breaks: {n_bugs + 1} bug{?s}")
#> 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
cli::pluralize("It's not an issue if you aren't actually pluralizing something: n_bugs^2 is {n_bugs^2}")
#> It's not an issue if you aren't actually pluralizing something: n_bugs^2 is 4611686014132420608
cli::pluralize("You can also go low: {-1L * .Machine$integer.max} bug{?s}")
#> You can also go low: -2147483647 bugs
cli::pluralize("...but not too low {-1L * .Machine$integer.max - 1} bug{?s}")
#> 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
Created on 2025-05-22 with reprex v2.0.2
- Dominant language
- R
- Stars
- 726
- Forks
- 94
- Avg merge
- 3h 35m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from r-lib/cli
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
feature
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·