[Rd] Include line number in the error messages regarding misuse of placeholder

Kun Ren renkun @end|ng |rom out|ook@com
Mon Mar 21 04:56:50 CET 2022

Hello, R maintainers,

We are discussing the changes needed for code linting in the lintr package development for the upcoming placeholder in a pipe at <https://github.com/r-lib/lintr/issues/959>.

First, thanks for implementing the feature!

While I'm playing with it and see what we could do to improve in code linting for it, I notice that the error messages produced by the parser regarding the misuse of placeholder do not contain anything about the line number, which makes it hard to tell user which line of code causes this error.

For example,

    parse(text = "data |> fun(mpg ~ cyl, data1 = _, data2 = _)")

produces the error "pipe placeholder may only appear once"

    parse(text = "mtcars |> lm(mpg ~ cyl, data = fun(_))")

produces the error "invalid use of pipe placeholder".

Neither contains a line number. Michael Chirico tried to include the correct line number (https://github.com/r-lib/lintr/issues/959#issuecomment-1073389513), but it seems non-trivial to do so.

We are wondering if it is possible to include a proper line number in these error messages, like some other messages that include it, so that user could know better about where the error occurs?

Best regards,
Kun Ren

More information about the R-devel mailing list