Skip to content

Commit cffb4a1

Browse files
Progress deprecation of with=FALSE + := (#6648)
* Progress deprecation of with=FALSE + := * missing " * Fix error, also later tests assumed success
1 parent 91b8a40 commit cffb4a1

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

NEWS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,12 @@ rowwiseDT(
176176
177177
9. `key<-`, marked as deprecated since 2012 and unusable since v1.15.0, has been fully removed.
178178
179-
10. Deprecation of `logicalAsInt` argument to `fwrite()` has been upgraded from a warning (since v1.15.0) to an error. It will be removed in the next release.
179+
10. The following in-progress deprecations have proceeded:
180180
181-
11. Deprecation of `fread(autostart=)` has been upgraded to an error. It has been warning since v1.11.0 (6 years ago). The argument will be removed in the next release.
182-
183-
12. Deprecation of `droplevels(in.place=TRUE)` (warning since v1.16.0) has been upgraded from warning to error. The argument will be removed in the next release.
181+
+ Using `fwrite(logicalAsInt=)` has been upgraded from a warning (since v1.15.0) to an error. It will be removed in the next release.
182+
+ Using `fread(autostart=)` has been upgraded to an error. It has been warning since v1.11.0 (6 years ago). The argument will be removed in the next release.
183+
+ Using `droplevels(in.place=TRUE)` (warning since v1.16.0) has been upgraded from warning to error. The argument will be removed in the next release.
184+
+ Use of `:=` and `with=FALSE` in `[` has been upgraded from warning (since v1.15.0) to error. Long ago (before 2014), this was needed when, e.g., assigning to a vector of column names defined outside the table, but `with=FALSE` is no longer needed to do so: `DT[, (cols) := ...]` works fine.
184185
185186
# data.table [v1.16.4](https://github.com/Rdatatable/data.table/milestone/36) 4 December 2024
186187

R/data.table.R

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -685,19 +685,11 @@ replace_dot_alias = function(e) {
685685
# j was substituted before dealing with i so that := can set allow.cartesian=FALSE (#800) (used above in i logic)
686686
if (is.null(jsub)) return(NULL)
687687

688-
if (!with && jsub %iscall% ":=") {
689-
# TODO: make these both errors (or single long error in both cases) in next release.
690-
# i.e. using with=FALSE together with := at all will become an error. Eventually with will be removed.
691-
if (is.null(names(jsub)) && is.name(jsub[[2L]])) {
692-
warningf("with=FALSE together with := was deprecated in v1.9.4 released Oct 2014. Please wrap the LHS of := with parentheses; e.g., DT[,(myVar):=sum(b),by=a] to assign to column name(s) held in variable myVar. See ?':=' for other examples. As warned in 2014, this is now a warning.")
693-
jsub[[2L]] = eval(jsub[[2L]], parent.frame(), parent.frame())
694-
} else {
695-
warningf("with=FALSE ignored, it isn't needed when using :=. See ?':=' for examples.")
696-
}
697-
with = TRUE
698-
}
699-
700688
if (!with) {
689+
if (jsub %iscall% ":=") {
690+
# TODO(>=1.18.0): Simplify this error
691+
stopf("with=FALSE together with := was deprecated in v1.9.4 released Oct 2014; this has been warning since v1.15.0. Please wrap the LHS of := with parentheses; e.g., DT[,(myVar):=sum(b),by=a] to assign to column name(s) held in variable myVar. See ?':=' for other examples.")
692+
}
701693
# missingby was already checked above before dealing with i
702694
if (jsub %iscall% c("!", "-") && length(jsub)==2L) { # length 2 to only match unary, #2109
703695
notj = TRUE

inst/tests/tests.Rraw

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,7 +4655,7 @@ test(1241, DT[order(x,-y)], # optimized to forder()
46554655

46564656
DT = data.table(a=1:3, b=4:6)
46574657
myCol = "a"
4658-
test(1242.1, DT[2,myCol:=6L,with=FALSE], data.table(a=INT(1,6,3), b=4:6), warning="with=FALSE together with := was deprecated in v1.9.4 released Oct 2014. Please")
4658+
test(1242.1, DT[2,myCol:=6L,with=FALSE], error="with=FALSE together with := was deprecated in v1.9.4")
46594659
test(1242.2, DT[2,(myCol):=7L], data.table(a=INT(1,7,3), b=4:6))
46604660

46614661
# consistency of output type of mult, #340
@@ -13953,8 +13953,8 @@ test(1967.42, x[3, rollends = rep(TRUE, 10L)], error = 'rollends must be length
1395313953
test(1967.43, x[ , ..], error = 'symbol .. is invalid')
1395413954
test(1967.44, x[NULL], data.table(NULL))
1395513955
test(1967.45, x[ , NULL], NULL)
13956-
test(1967.46, x[ , 'b' := 6:10, with = FALSE],
13957-
data.table(a = 1:5, b = 6:10), warning = 'with=FALSE ignored')
13956+
test(1967.46, x[ , 'b' := 6:10, with=FALSE], error='with=FALSE together with :=')
13957+
x[, b := 6:10]
1395813958
test(1967.47, x[ , -1L, with = FALSE], data.table(b = 6:10))
1395913959
test(1967.48, x[ , b, .SDcols = 'a'], 6:10,
1396013960
warning = "This j doesn't use .SD")

0 commit comments

Comments
 (0)