Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2862,6 +2862,9 @@ set = function(x,i=NULL,j,value) # low overhead, loopable
setalloccol(x, verbose=FALSE)
if (is.name(name)) {
assign(as.character(name), x, parent.frame(), inherits=TRUE)
} else if (is.call(name)) {
# handle subexpressions like self$dt, foo[["bar"]], etc. by evaluating the assignment in parent frame
eval(call("<-", name, x), parent.frame())
}
}
.Call(Cassign,x,i,j,NULL,value)
Expand Down
8 changes: 7 additions & 1 deletion inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -21906,7 +21906,13 @@ null_in_value <- NULL
test(2351.3, "cyl" %notin% names(DT[, cyl := null_in_value]))
DT = unserialize(serialize(as.data.table(mtcars), NULL))
test(2351.4, ncol(DT[, c("cyl", "mpg") := .(null_in_value, null_in_value)]), ncol(mtcars) - 2L)
rm(DT)
l = list(DT = unserialize(serialize(as.data.table(mtcars), NULL)))
test(2351.5, set(l$DT, j="carb", value=NULL), as.data.table(mtcars)[,carb:=NULL])
test(2351.6, "carb" %notin% names(l$DT))
l = list(DT = unserialize(serialize(as.data.table(mtcars), NULL)))
test(2351.7, set(l[["DT"]], j="carb", value=NULL), as.data.table(mtcars)[,carb:=NULL])
test(2351.8, "carb" %notin% names(l$DT))
rm(DT, l)

# rbindlist did not protect the temporary UTF-8 strings, #7452
DTn = apply(matrix(as.raw(rep(0xa1:0xff, length.out = 100)), 10), 2, rawToChar)
Expand Down
Loading