From 7f5a437b2ab0da8c7f3a7cc6127c107b1b17e50f Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sat, 22 Feb 2025 22:37:11 -0800 Subject: [PATCH 1/2] Simplify error for !with + := --- R/data.table.R | 5 +---- inst/tests/tests.Rraw | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/R/data.table.R b/R/data.table.R index 34e995807..5c568a9bb 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -686,10 +686,7 @@ replace_dot_alias = function(e) { if (is.null(jsub)) return(NULL) if (!with) { - if (jsub %iscall% ":=") { - # TODO(>=1.18.0): Simplify this error - 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.") - } + if (jsub %iscall% ":=") stopf("`:=` is only supported under with=TRUE.") # missingby was already checked above before dealing with i if (jsub %iscall% c("!", "-") && length(jsub)==2L) { # length 2 to only match unary, #2109 notj = TRUE diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index ea3a91470..f7a2f87a8 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -4629,7 +4629,7 @@ test(1241, DT[order(x,-y)], # optimized to forder() DT = data.table(a=1:3, b=4:6) myCol = "a" -test(1242.1, DT[2,myCol:=6L,with=FALSE], error="with=FALSE together with := was deprecated in v1.9.4") +test(1242.1, DT[2,myCol:=6L,with=FALSE], error="`:=` is only supported under with=TRUE.") test(1242.2, DT[2,(myCol):=7L], data.table(a=INT(1,7,3), b=4:6)) # consistency of output type of mult, #340 @@ -13926,7 +13926,7 @@ test(1967.42, x[3, rollends = rep(TRUE, 10L)], error = 'rollends must be length test(1967.43, x[ , ..], error = 'symbol .. is invalid') test(1967.44, x[NULL], data.table(NULL)) test(1967.45, x[ , NULL], NULL) -test(1967.46, x[ , 'b' := 6:10, with=FALSE], error='with=FALSE together with :=') +test(1967.46, x[ , 'b' := 6:10, with=FALSE], error='`:=` is only supported under with=TRUE.') x[, b := 6:10] test(1967.47, x[ , -1L, with = FALSE], data.table(b = 6:10)) test(1967.48, x[ , b, .SDcols = 'a'], 6:10, From 41c49c1ec4177130862abc2b2eb6d0d249d61929 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 10 Mar 2025 12:38:47 -0700 Subject: [PATCH 2/2] help nudge --- R/data.table.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.table.R b/R/data.table.R index 5c568a9bb..ce091c8ad 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -686,7 +686,7 @@ replace_dot_alias = function(e) { if (is.null(jsub)) return(NULL) if (!with) { - if (jsub %iscall% ":=") stopf("`:=` is only supported under with=TRUE.") + if (jsub %iscall% ":=") stopf("`:=` is only supported under with=TRUE, see ?`:=`.") # missingby was already checked above before dealing with i if (jsub %iscall% c("!", "-") && length(jsub)==2L) { # length 2 to only match unary, #2109 notj = TRUE