# fake pronoun fails informatively Code # Fake pronouns f <- (function() .data$foo) (expect_error(f(), "subset")) Output Error in `f()`: ! Can't subset `.data` outside of a data mask context. Code f <- (function() .data[["foo"]]) (expect_error(f(), "subset")) Output Error in `f()`: ! Can't subset `.data` outside of a data mask context. # `.data` pronoun fails informatively Code (expect_error(f())) Output Error in `g()`: ! Can't subset `.data` outside of a data mask context. Code (expect_error(f(mtcars))) Output Error in `.data$foo`: ! Column `foo` not found in `.data`. Code g <- (function(data) h(.data[[2]], data)) (expect_error(f(mtcars))) Output Error in `.data[[2]]`: ! Must subset the data pronoun with a string, not the number 2. Code g <- (function(data) h(.data["foo"], data = data)) (expect_error(f(mtcars))) Output Error in `.data["foo"]`: ! `[` is not supported by the `.data` pronoun, use `[[` or $ instead. Code g <- (function(data) h(.data[["foo"]] <- 1, data = data)) (expect_error(f(mtcars))) Output Error in `.data[["foo"]] <- ...`: ! Can't modify the data pronoun. Code g <- (function(data) h(.data$foo <- 1, data = data)) (expect_error(f(mtcars))) Output Error in `.data$"foo" <- ...`: ! Can't modify the data pronoun. Code g <- (function(data) h(.env["foo"], data = data)) (expect_error(f(mtcars))) Output Error in `.env["foo"]`: ! `[` is not supported by the `.env` pronoun, use `[[` or $ instead. Code g <- (function(data) h(.env$foo <- 1, data = data)) (expect_error(f(mtcars))) Output Error in `.env$"foo" <- ...`: ! Can't modify the context pronoun. Code g <- (function(data) h(.env[["foo"]] <- 1, data = data)) (expect_error(f(mtcars))) Output Error in `.env[["foo"]] <- ...`: ! Can't modify the context pronoun.