Skip to content

Commit

Permalink
Closes #880. eval(parse(.)) issue in j
Browse files Browse the repository at this point in the history
  • Loading branch information
arunsrinivasan committed Oct 12, 2014
1 parent 9bd554a commit d4cad4d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ deconstruct_and_eval = function(expr, envir = parent.frame(), enclos = parent.fr
}
ff <- function(m) {
if (is.call(m)) {
if (m[[1L]] == quote(eval))
deconstruct_and_eval(eval(m[[2L]], envir, enclos), envir, enclos)
if (m[[1L]] == quote(eval))
# fix for #880. Hopefully this resolve the eval(parse(.)) issue for good.
if (is.call(m[[2L]]) && m[[2L]][[1L]] == quote(parse))
deconstruct_and_eval(m, envir, enclos)
else deconstruct_and_eval(eval(m[[2L]], envir, enclos), envir, enclos)
else deconstruct_and_eval(m, envir, enclos)
} else m
}
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
11. `format.ITime` now handles negative values properly. Closes [#811](https://github.com/Rdatatable/data.table/issues/811). Thanks to @StefanFritsch for the report along with the fix!

12. Compatibility with big endian machines (e.g., SPARC and PowerPC) is restored. Most Windows, Linux and Mac systems are little endian; type `.Platform$endian` to confirm.


13. `DT[, LHS := RHS]` with RHS is of the form `eval(parse(text = foo[1]))` referring to columns in `DT` is now handled properly. Closes [#880](https://github.com/Rdatatable/data.table/issues/880). Thanks to tyner.

#### NOTES

Expand Down
5 changes: 5 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -5361,6 +5361,11 @@ x = c(1L, -1L, -3700L)
class(x) = "ITime"
test(1388, as.character(x), c("00:00:01", "-00:00:01", "-01:01:40"))

# Fix for #880. Another eval(parse(.)) issue.
DT <- as.data.table(iris)
DT[, foo := "Species"]
test(1389, copy(DT)[,bar := eval(parse(text=foo[1]), envir=.SD)], copy(DT)[, bar := Species])

##########################


Expand Down

0 comments on commit d4cad4d

Please sign in to comment.