Skip to content

Commit 5ad0080

Browse files
Allow setDT(get(...)) to work as previously
1 parent e0abdfc commit 5ad0080

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

R/data.table.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,11 @@ setDT = function(x, keep.rownames=FALSE, key=NULL, check.names=FALSE) {
29872987
} else if (isS4(k)) {
29882988
.Call(CsetS4elt, k, as.character(name[[3L]]), x)
29892989
}
2990+
} else if (name %iscall% "get") { # #6725
2991+
name = match.call(get, name)
2992+
name[[1L]] = quote(assign)
2993+
name$value = quote(x)
2994+
eval(name)
29902995
}
29912996
.Call(CexpandAltRep, x) # issue#2866 and PR#2882
29922997
invisible(x)

inst/tests/tests.Rraw

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20653,6 +20653,14 @@ setDT(d2)
2065320653
test(2295.1, !is.data.table(d1))
2065420654
test(2295.2, rownames(d1), 'b')
2065520655
test(2295.3, is.data.table(d2))
20656+
# Ensure against regression noted in #6725
20657+
x = data.frame(a=1)
20658+
e = environment()
20659+
foo = function() {
20660+
setDT(get('x', envir=e))
20661+
}
20662+
foo()
20663+
test(2295.4, is.data.table(x))
2065620664

2065720665
# #6588: .checkTypos used to give arbitrary strings to stopf as the first argument
2065820666
test(2296, d2[x %no such operator% 1], error = '%no such operator%')

0 commit comments

Comments
 (0)