Skip to content

Coping with non-standard evaluation in R program analysis

2 messages · jan Vitek, Gabriel Becker

#
Hi Evan,

You may find some parts of what we are doing with genthat useful.  Genthat is a tool
for creating unit tests by recording argument and return values of calls. This is
done by instrumentation of the source code.

The git repo with the code is here https://github.com/PRL-PRG/genthat

We don?t really deal with NSE though. It could be something worth thinking about for us.
The contact for genthtat is Filip.


We are also writing a tool for analyzing promises and generating execution traces
within the R VM.  This is available in 
    https://github.com/PRL-PRG/R-dyntrace

Aviral and Konrad are the contacts there.


Best,

jan






Jan Vitek, Professor 
Computer Science, 
Northeastern University
14 days later
#
Evan,

You can look at what CodeDepends (on cran/ github.com/duncantl/CodeDepends
) does for nonstandard evaluation. It is a static code analyzer which
allows for custom handler functions for calls to specific functions. The
default handlers provided are "NSE-aware" (many of) the common contexts
where that occurs. It then consumes arguments to those functions as NSE and
annotates them accordingly in the result. This is a heuristic, and we don't
currently do the harder bit of attempting to figure out where those
non-standard symbols will be resolved currently, but it's potentially a
start.

As for manipulating the AST, do be somewhat careful of this. You may run
afoul of other things that are doing this under the hood based on
particular assumptions, notably the rlang stuff that backs the tidyverse
these days.  You might be safe though, it depends on what you want.

Another approach is what I in the histry package, which handles top-level
expressions in both interactive session and dynamic document weaving
contexts. Happy to talk more about this off list as I have done a fair bit
of work in the space it sounds like you're in.

Best,
~G
On Thu, Jan 4, 2018 at 12:20 AM, jan Vitek <vitekj at icloud.com> wrote: