Skip to content

Bug: Package detection failure for backtick-quoted functions in get_used_functions #271

@AbhaySThakur

Description

@AbhaySThakur

What happened?

When using logrx::axecute() to execute R code, the function fails to correctly detect the source package for any function that is called using backtick notation (e.g., colnames<- ). This issue consistently occurs with special operator functions.

Below is the screenshot of how it appears in the log
Image

Comparison of same code written in two different ways.

# Version 1: Works correctly - properly identified as from 'base' package
colnames(dataset1) <- c("A1", "B1")

# Version 2: Fails to detect 'base' package
dataset1 <- `colnames<-`(dataset1, c("A1", "B1"))

I checked this affects all functions with similar syntax patterns, not just colnames<-

Session Information

No response

Reproducible Example

Below is an reprex example to replicate the issue.
Note that function form is not detected to be from base package.

# Temporary work area
tmpDir <- tempdir()
rcode <- file.path(tmpDir, "test2.R")
rlog  <- file.path(tmpDir, "test2.log")

# Write code that will generate an error to the test file
rcode_text <- c(
  "df <- data.frame(a =1, b=2)",
  "df <- `colnames<-`(df , c('A1', 'B1'))",
  "colnames(df)"
)
writeLines(rcode_text, con = rcode)

logrx:::get_used_functions(rcode)
#> # A tibble: 4 × 2
#>   function_name library          
#>   <chr>         <chr>            
#> 1 data.frame    package:base     
#> 2 `colnames<-`  !!! NOT FOUND !!!
#> 3 c             package:base     
#> 4 colnames      package:base

Created on 2025-08-28 with reprex v2.1.1

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions