Skip to content

Error in rep.int(character, length) : invalid 'times' value when using incomplete |> in rmarkdown file #1737

Closed
@milanglacier

Description

@milanglacier

I am using r-lib/lintr version a32f2d2, and the R version is 4.2.0 on macOS

suppose we have following test.rmd file:

https://pastebin.com/zMjAth9E

(I attach it as pastebin because rmarkdown syntax may conflict with github markdown syntax)

notably, an incomplete pip operator will fail

test = 10
test |>

and lintr::lint("test.rmd") will yield following error:

Error in rep.int(character, length) : invalid 'times' value

traceback:

9: paste0(collapse = "", rep.int(character, length))
8: fill_with(" ", maximum)
7: highlight_string(x$message, x$column_number, x$ranges)
6: cat(sep = "", emph(x$filename, ":", as.character(x$line_number), 
       ":", as.character(x$column_number), ": ", sep = ""), color(x$type, 
       ": ", sep = ""), "[", x$linter, "] ", emph(x$message), "\n", 
       chartr("\t", " ", x$line), "\n", highlight_string(x$message, 
           x$column_number, x$ranges), "\n")
5: print.lint(X[[i]], ...)
4: FUN(X[[i]], ...)
3: lapply(x, print, ...)
2: print.lints(x)
1: (function (x, ...) 
   UseMethod("print"))(x)

also note, in R script an incomplete |> will not issue an error, instead such error can be correctly linted:

lintr::lint("test.R")

r$> lintr::lint("test.R")
/Users/northyear/Downloads/test/test.R:21:6: error: [error] unexpected end of input
cat |>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions