Skip to content

Pluralization with empty last alternative produces the wrong output #158

@rundel

Description

@rundel

I have a slightly odd use case where I was trying to "pluralize" the verb exist and ran into the an issue where {?s/} is being treated as {?s}.

vars = c("X")
cli::cli_text("{vars} exist{?s/}")
#> X exist
cli::cli_text("{vars} exist{?s}") 
#> X exist

vars = c("X","Y")
cli::cli_text("{vars} exist{?s/}")
#> X and Y exists
cli::cli_text("{vars} exist{?s}") 
#> X and Y exists

it seems like this may be a more general issue with a trailing empty alternative:

vars = c()
cli::cli_text("{vars} word{?A/B/C}") # Ok
#> wordA
cli::cli_text("{vars} word{?/B/C}")  # Ok
#> word
cli::cli_text("{vars} word{?A//C}")  # Ok
#> wordA
cli::cli_text("{vars} word{?A/B/}")  # Wrong
#> wordB

vars = c("X")
cli::cli_text("{vars} word{?A/B/C}") # Ok
#> X wordB
cli::cli_text("{vars} word{?/B/C}")  # Ok
#> X wordB
cli::cli_text("{vars} word{?A//C}")  # Ok
#> X word
cli::cli_text("{vars} word{?A/B/}")  # Wrong
#> X wordA

vars = c("X","Y")
cli::cli_text("{vars} word{?A/B/C}") # Ok
#> X and Y wordC
cli::cli_text("{vars} word{?/B/C}")  # Ok
#> X and Y wordC
cli::cli_text("{vars} word{?A//C}")  # Ok
#> X and Y wordC
cli::cli_text("{vars} word{?A/B/}")  # Wrong
#> X and Y wordB

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions