pharmaverse / pharmaverse/logrx
Bug: Package detection failure for backtick-quoted functions in `get_used_functions`
Open
bug
- Dominant language
- HTML
- Stars
- 48
- Forks
- 12
- Avg merge
- 20d 8h
- Merged PRs (30d)
- 1
Description
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
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.