r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
498 stars 136 forks source link

Never keep sources in `parse_*()` #1604

Closed DavisVaughan closed 1 year ago

DavisVaughan commented 1 year ago

Closes #1603

It turns out that in both rlang 1.0.6 and 1.1.0, source information was already being dropped in all cases (I wanted to ensure that removing usage of flatten() was not the result of this change, and it doesn't seem to be).

I think this makes sense as the source reference information is typically attached to the expression object, and:

DavisVaughan commented 1 year ago

I suppose you can manually merge the srcref list, but I'm not sure what you'd do with $wholeSrcref here

attributes(parse(text = "foo(); bar"))
#> $srcref
#> $srcref[[1]]
#> foo()
#> 
#> $srcref[[2]]
#> bar
#> 
#> 
#> $srcfile
#> <text> 
#> 
#> $wholeSrcref
#> foo(); bar

attributes(parse(text = "baz"))
#> $srcref
#> $srcref[[1]]
#> baz
#> 
#> 
#> $srcfile
#> <text> 
#> 
#> $wholeSrcref
#> baz
lionel- commented 1 year ago

hmm I think this attribute is not required.