Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing commas cause problems with functions accessed via $ #266

Closed
kamilzyla opened this issue Feb 8, 2022 · 1 comment
Closed

Trailing commas cause problems with functions accessed via $ #266

kamilzyla opened this issue Feb 8, 2022 · 1 comment

Comments

@kamilzyla
Copy link
Contributor

Error description

Assume we have the following module.R:

header <- function() {
  tags$span(
    "Hello!",
  )
}

Now box::use(./module) results in Error in box::use(./module) : argument "fun" is missing, with no default. The problem can be fixed by removing tags$ or the trailing comma:

# Works either way
header <- function() tags$span("Hello!")
header <- function() span("Hello!", )

The example was inspired by shiny::tags$span() which accepts trailing commas, but tags don't need to be defined to encounter the issue above.

The issue seemed related to #263 which I reported earlier, but it still occurs on the dev branch (tested after installing with remotes::install_github("klmr/box@9fb08c6")).

R version

platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          1.1                         
year           2021                        
month          08                          
day            10                          
svn rev        80725                       
language       R                           
version.string R version 4.1.1 (2021-08-10)
nickname       Kick Things

‘box’ version

1.1.9000

@klmr
Copy link
Owner

klmr commented Feb 13, 2022

Thanks for the report. It’s actually unrelated to #263 even though it looks so similar. This error is due to the code that tries to find S3 generics. To do this it traverses the syntax tree of each function, and apparently it fails to account for missing arguments in the case where a function isn’t a simple name. The fix is straightforward, I just hope that I am not missing other cases with this logic.

Once the builds have run, you can install this bugfix build via

install.packages('box', repos = 'https://klmr.r-universe.dev')

radbasa pushed a commit to Appsilon/box that referenced this issue Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants