rlang icon indicating copy to clipboard operation
rlang copied to clipboard

"inserting non-tracking CDR in tracking cell" in `eval_quo()` with strict write barrier

Open krlmlr opened this issue 1 year ago • 0 comments

Setting a data frame column in a data frame named df or nrow gives an interesting error message with R built with --enable-strict-barrier . This doesn't happen with a data frame named dim or x, or when evaluating with eval() . Is this triggered by the data frame object having the same name as a function (but not a primitive)?

new_df <- function() {
  data.frame(n = 0)
}

df <- new_df()
df[[1]] <- 1
df
#>   n
#> 1 1

library(rlang)

df <- new_df()
eval_tidy(quo(df[[1]] <- 1))
#> Error in df[[1]] <- 1: inserting non-tracking CDR in tracking cell

nrow <- new_df()
eval_tidy(quo(nrow[[1]] <- 1))
#> Error in nrow[[1]] <- 1: inserting non-tracking CDR in tracking cell

dim <- new_df()
eval_tidy(quo(dim[[1]] <- 1))

x <- new_df()
full_code <- rlang::quo(x[[1]] <- 1)
rlang::eval_tidy(full_code)

Created on 2023-03-04 with reprex v2.0.2

krlmlr avatar Mar 04 '23 05:03 krlmlr