On Fri, 31 Mar 2023 08:49:53 +0200
Lionel Henry <lionel at posit.co> wrote:
If you can afford a dependency on rlang, `rlang::zap_srcref()` deals with this. It's recursive over expression vectors, calls (including calls to `function` and their hidden srcref arg), and function objects.
Thanks for the suggestion! I hope that the source reference argument in the `function` calls is the last way a source reference could sneak by in an expression obtained using substitute().
It's implemented in C for efficiency as we found it to be a bottleneck in some applications (IIRC caching). I'd be happy to upstream this in base if R core is interested.
A removeSource() that handles all the corner cases would be a nice improvement.
Best regards, Ivan