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

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Thu Apr 21 20:23:38 CEST 2022


The basic idea for a patch is that the bison/yacc variables &@1, &@2 and 
&@3 give the locations for the three parts of the pattern

    expr PIPE expr

I'll see if I can put together a minimal change that makes these 
available when the error messages are generated.

Duncan Murdoch

On 21/04/2022 12:47 p.m., luke-tierney using uiowa.edu wrote:
> [Apologies for the late reply. About a month ago our wonderful
> Exchange server apparently started to dump messages into Junk Email
> again even though I had turned that "feature" off, and I just noticed
> a couple of days ago.]
> 
> In principle I'd be happy to consider a simple patch to gram.y that
> add line numbers. I can't see the benefit of a complicated patch that
> makes the grammar even harder to maintain than it is already as being
> worth the cost. If you can come up with a simple. well tested patch
> please submit via bugzilla.
> 
> Best,
> 
> luke
> 
> On Mon, 21 Mar 2022, Kun Ren wrote:
> 
>> 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
>> ______________________________________________
>> R-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>



More information about the R-devel mailing list