Skip to content

case_when() error path isn't working correctly #6261

@DavisVaughan

Description

@DavisVaughan
library(dplyr)

# check_type
case_when(TRUE ~ 1, TRUE ~ "x")
#> Error in names(message) <- `*vtmp*`: 'names' attribute [1] must be the same length as the vector [0]

# check_class
case_when(TRUE ~ 1, TRUE ~ structure(1, class = "foo"))
#> Error in names(message) <- `*vtmp*`: 'names' attribute [1] must be the same length as the vector [0]

These are supposed to report on invalid types and classes, respectively.

This happens because we are missing an argument here in replace_with(). That NULL is probably intended to be passed on to reason, but it is instead being matched to name and that doesn't work. A character name is required for that error path to run correctly.

out <- replace_with(out, query[[i]] & !replaced, value[[i]], NULL, error_call = error_call)

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