Skip to content

Parser bug? "mismatched braces" #1492

@MichaelChirico

Description

@MichaelChirico

I think this comes down to whether or not we are supposed to escape things ourselves in @examples? In any case it took a looong time to figure out what could be going wrong here. I hadn't the slightest inkling to check the % tokens until I popped into the parser C++, so at a minimum we should try and improve the error message.

#' A function
#' @examples
#' \dontrun{
#' # glue::glue(R"['{format(Sys.Date(), "%Y%m%d")}']")
#' # glue::glue(R"['{format(Sys.Date() - 1, "%Y%m%d")}']")
#' }
#' @export
foo <- function() invisible()

roxygenize() will warn:

[foo.R:2] @examples has mismatched braces or quotes

It's extra puzzling since whatever may be mismatched is happening inside a code comment, so I'm surprised it's even evaluated to begin with?

Note that the source comment is required -- uncommenting silences the warning:

#' A function
#' @examples
#' \dontrun{
#' glue::glue(R"['{format(Sys.Date(), "%Y%m%d")}']")
#' glue::glue(R"['{format(Sys.Date() - 1, "%Y%m%d")}']")
#' }
#' @export
foo <- function() invisible()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorrd ✍️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions