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

Regression: ‘roxygen2’ 7.3.0 fails to parse name of S3 method for class { #1575

Closed
klmr opened this issue Jan 16, 2024 · 2 comments · Fixed by #1576
Closed

Regression: ‘roxygen2’ 7.3.0 fails to parse name of S3 method for class { #1575

klmr opened this issue Jan 16, 2024 · 2 comments · Fixed by #1576
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@klmr
Copy link
Contributor

klmr commented Jan 16, 2024

MWE:

dir.create('test/R', recursive = TRUE)
writeLines(
    r'[f = function (x) UseMethod('f')
`f.(` = function (x) x
`f.{` = function (x) x]',
    'test/R/test.r'
)

desc = list(
    Package = 'Test',
    Version = '0.0.1',
    License = 'MIT = file',
    Description = 'For testing.',
    Title = 'For Testing',
    `Authors@R` = 'person("F", "L", role = c("cre", "aut"))'
)
write.dcf(desc, 'test/DESCRIPTION')

roxygen2::roxygenize('test')

This leads to:

First time using roxygen2. Upgrading automatically...
Setting `RoxygenNote` to "7.3.0"
✖ roxygen2 requires "Encoding: UTF-8"
ℹ Current encoding is NA
ℹ Loading Test
Error in `map2()`:
ℹ In index: 1.
ℹ With name: f.{.
Caused by error in `glue()`:
! Unterminated quote (`)
Run `rlang::last_trace()` to see where the error occurred.
rlang::last_trace(drop = FALSE):
<error/purrr_error_indexed>
Error in `map2()`:
ℹ In index: 1.
ℹ With name: f.{.
Caused by error in `glue()`:
! Unterminated quote (`)
---
Backtrace:
     ▆
  1. ├─roxygen2::roxygenize("test")
  2. │ └─base::lapply(...)
  3. │   ├─roxygen2 (local) FUN(X[[i]], ...)
  4. │   └─roxygen2:::roclet_process.roclet_namespace(X[[i]], ...)
  5. │     └─roxygen2:::warn_missing_s3_exports(blocks, env)
  6. │       └─purrr::map2(undocumented, messages, warn_roxy_function)
  7. │         └─purrr:::map2_("list", .x, .y, .f, ..., .progress = .progress)
  8. │           ├─purrr:::with_indexed_errors(...)
  9. │           │ └─base::withCallingHandlers(...)
 10. │           ├─purrr:::call_with_cleanup(...)
 11. │           └─roxygen2 (local) .f(.x[[i]], .y[[i]], ...)
 12. │             └─roxygen2:::warn_roxy(file, line, message, parent = parent, envir = envir)
 13. │               └─cli::cli_inform(message, parent = parent, .envir = envir)
 14. │                 ├─rlang::inform(format_message(message, .envir = envir), ...)
 15. │                 │ └─message %||% ""
 16. │                 └─cli::format_message(message, .envir = .envir)
 17. │                   ├─cli::cli_fmt(...)
 18. │                   │ └─cli:::cli__rec(expr)
 19. │                   └─(function() {...
 20. │                     └─cli::cli_bullets(message, .envir = .envir)
 21. │                       ├─cli:::cli__message(...)
 22. │                       │ └─"id" %in% names(args)
 23. │                       ├─base::structure(lapply(text, glue_cmd, .envir = .envir), names = names(text))
 24. │                       └─base::lapply(text, glue_cmd, .envir = .envir)
 25. │                         └─cli (local) FUN(X[[i]], ...)
 26. │                           └─cli:::glue(...)
 27. └─base::.handleSimpleError(...)
 28.   └─purrr (local) h(simpleError(msg, call))
 29.     └─cli::cli_abort(...)
 30.       └─rlang::abort(...)

The offending package code is:

f = function (x) UseMethod('f')

`f.(` = function (x) x

`f.{` = function (x) x

Note that f.( is accepted, only f.{ causes an error.

The usage in actual code (in the ‘box’ package) needs this to dispatch on the type of an unevaluated R expression for an AST walker.

@klmr klmr changed the title Regression: ‘roxygen2’ 7.3.0 fails to parse name for S3 class { Regression: ‘roxygen2’ 7.3.0 fails to parse name of S3 method for class { Jan 16, 2024
@klmr
Copy link
Contributor Author

klmr commented Jan 16, 2024

I should mention that this breaks a package on CRAN. It was presumably not caught by the revdep checks because it’s only a build dependency (and hence “Suggests”).

@hadley
Copy link
Member

hadley commented Jan 22, 2024

And now on CRAN 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants