Skip to content

Empty lines in function calls results in an error #94

@Iain-S

Description

@Iain-S

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Locale: en_GB.UTF-8 / en_GB.UTF-8 / en_GB.UTF-8 / C / en_GB.UTF-8 / en_GB.UTF-8
Package version:
formatR_1.11.1

Minimal Reproducible Example

At least some of the time (perhaps all of the time) having two empty lines between function call parens causes formatR to error. However, it appears to be valid R syntax (verified by running it in R).

mre.R

print(


)
> formatR::tidy_file("mre.R", indent=2, arrow=TRUE, args.newline=TRUE)
tidying mre.R
Error in base::parse(text = code, keep.source = FALSE) :
  <text>:3:1: unexpected symbol
2: invisible(".BeGiN_TiDy_IdEnTiFiEr_HaHaHa.HaHaHa_EnD_TiDy_IdEnTiFiEr")
3: invisible

Conversely, having only one empty line in the function call does not throw an error but does result in incorrect behaviour

mre2.R (before)

print(

)
> formatR::tidy_file("mre2.R")
tidying mre2.R

mre2.R (after)

print() print()

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('formatR'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/formatR').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions