Skip to content

str_replace_all errors with multiple matches, a named string vector, and a function replacement #595

@hughjonesd

Description

@hughjonesd

The first call below errors. The others are fine.

# Named arguemnt
stringr::str_replace_all(c(name = "string string"), "string", function (x) rep("strong", length(x)))
Error in `vctrs::list_unchop()`:
! Can't merge the outer name `name` with a vector of length > 1.
Please supply a `.name_spec` specification.
Run `rlang::last_trace()` to see where the error occurred.

Enter a frame number, or 0 to exit   

1: stringr::str_replace_all(c(name = "string string"), "string", function(x) rep("strong",
2: str_transform_all(string, pattern, replacement)
3: vctrs::list_unchop(old)
4: abort(message = message)
5: signal_abort(cnd, .file)

Selection: 0

# Unnamed argument
stringr::str_replace_all(c("string string"), "string", function (x) rep("strong", length(x)))
[1] "strong strong"

# Character replacement
stringr::str_replace_all(c(name = "string string"), "string", "strong")
           name 
"strong strong" 

# Single match
stringr::str_replace_all(c(name = "string"), "string", function (x) rep("strong", length(x)))
[1] "strong"

This is (I think) new in 1.6.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions