Skip to content

Inconsistency when referring to a function programmatically #26

Description

@jonthegeek

If I refer to a function via a variable, the class column of s3_methods_generic isn't what I'd expect.

this_func <- mean
sloop::s3_methods_generic("this_func")
#> Warning in .S3methods(generic.function, class, envir): generic function
#> 'this_func' dispatches methods for generic 'mean'
#> # A tibble: 6 x 4
#>   generic class         visible source                      
#>   <chr>   <chr>         <lgl>   <chr>                       
#> 1 mean    mean.Date     TRUE    base                        
#> 2 mean    mean.default  TRUE    base                        
#> 3 mean    mean.difftime TRUE    base                        
#> 4 mean    mean.POSIXct  TRUE    base                        
#> 5 mean    mean.POSIXlt  TRUE    base                        
#> 6 mean    mean.quosure  FALSE   registered S3method for mean
sloop::s3_methods_generic("mean")
#> # A tibble: 7 x 4
#>   generic class      visible source             
#>   <chr>   <chr>      <lgl>   <chr>              
#> 1 mean    Date       TRUE    base               
#> 2 mean    default    TRUE    base               
#> 3 mean    difftime   TRUE    base               
#> 4 mean    POSIXct    TRUE    base               
#> 5 mean    POSIXlt    TRUE    base               
#> 6 mean    quosure    FALSE   registered S3method
#> 7 mean    vctrs_vctr FALSE   registered S3method

We already have the "generic" column from utils::method, should it use that for generating the "class" column (rather than x)?

I can PR if there isn't a reason to use the generic_esc that I'm not thinking of; using info from methods seems safer.

Activity

  1. added
    bugan unexpected problem or unintended behavior
    on Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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