From ||one| @end|ng |rom r@tud|o@com  Thu Sep  3 00:19:02 2020
From: ||one| @end|ng |rom r@tud|o@com (Lionel Henry)
Date: Thu, 3 Sep 2020 00:19:02 +0200
Subject: [Rd] sys.call() 's srcref doesn't match the language
In-Reply-To: <CAEKh8uj_2n00yYaaqqV6wH9th5eNebDzDFXe-yrVE9Hgqt8b2A@mail.gmail.com>
References: <CAEKh8uj_2n00yYaaqqV6wH9th5eNebDzDFXe-yrVE9Hgqt8b2A@mail.gmail.com>
Message-ID: <CAJf4E3pK1m5W+-OwtvLE-Je11uDhEu2y76PuRB03UxLNvh-kmQ@mail.gmail.com>

Hello,

The source references are useful for debugging tools because they
allow linking to call sites in the source files.

I agree the output can be confusing. Perhaps this could be fixed by
tweaking the print method for calls. If the deparsed call doesn't
match the srcref, both could be displayed along with file:line:column.

```
#> f()
#> <srcref:file.R:2:3>
#> 1 + f()
```

Best,
Lionel


On 9/2/20, Antoine Fabri <antoine.fabri at gmail.com> wrote:
> Dear R-devel,
>
> I found this behavior disturbing, if `1 + f()` is called, `sys.call()`
> called inside of `f` will return a quoted `f()` with a "srcref" that prints
> "1 + f()".
>
> I don't know which one is good but I don't think they can be correct at the
> same time.
>
> Here's a reproducible example:
>
> f <- function(){
>   sc <- sys.call()
>   print(sc)
>   attr(sc, "srcref") <- NULL
>   print(sc)
>   1
> }
> f2 <- function() {
>   1 + f()
> }
> f()
> #> f()
> #> f()
> #> [1] 1
> f2()
> #> 1 + f()
> #> f()
> #> [1] 2
>
> Best,
>
> Antoine
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] sys.call() 's srcref doesn't match the language
Lionel Henry