You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test(2005.11, set(DT, 1L, "e", expression(x+2)), error="type 'expression' cannot be coerced to 'double'")
14481
14481
test(2005.12, set(DT, 1L, "f", expression(x+2)), error="type 'expression' cannot be coerced to 'complex'")
14482
14482
test(2005.30, DT[2:3,c:=c(TRUE,FALSE), verbose=3L]$c, as.raw(INT(7,1,0)), ## note verbose=3L for more deeper verbose output due to memrecycle messages when it is being re-used internally #4491
14483
-
output="Zero-copy coerce when assigning 'logical' to 'raw' column 3 named 'c'")
14483
+
output="Zero-copy coerce when assigning 'logical' to column 3 named 'c' which is 'raw'")
// 'where' a 1-based INTEGER vector subset of target to assign to, or NULL or integer()
@@ -792,7 +786,10 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
792
786
for (inti=0; i<slen; ++i) {
793
787
constintval=sd[i+soff];
794
788
if ((val<1&&val!=NA_INTEGER) ||val>nlevel) {
795
-
error(_("Assigning factor numbers to %s. But %d is outside the level range [1,%d]"), targetDesc(colnum, colname), val, nlevel);
789
+
if (colnum==0)
790
+
error(_("Assigning factor numbers to target vector. But %d is outside the level range [1,%d]"), val, nlevel);
791
+
else
792
+
error(_("Assigning factor numbers to column %d named '%s'. But %d is outside the level range [1,%d]"), colnum, colname, val, nlevel);
796
793
}
797
794
}
798
795
} else {
@@ -801,7 +798,10 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
801
798
constdoubleval=sd[i+soff];
802
799
// Since nlevel is an int, val < 1 || val > nlevel will deflect UB guarded against in PR #5832
803
800
if (!ISNAN(val) && (val<1||val>nlevel||val!= (int)val)) {
804
-
error(_("Assigning factor numbers to %s. But %f is outside the level range [1,%d], or is not a whole number."), targetDesc(colnum, colname), val, nlevel);
801
+
if (colnum==0)
802
+
error(_("Assigning factor numbers to target vector. But %f is outside the level range [1,%d], or is not a whole number."), val, nlevel);
803
+
else
804
+
error(_("Assigning factor numbers to column %d named '%s'. But %f is outside the level range [1,%d], or is not a whole number."), colnum, colname, val, nlevel);
805
805
}
806
806
}
807
807
}
@@ -893,27 +893,38 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
warning(_("Coercing 'character' RHS to '%s' to match the type of %s."), targetIsI64?"integer64":type2char(TYPEOF(target)), targetDesc(colnum, colname));
896
+
if (colnum==0)
897
+
warning(_("Coercing 'character' RHS to '%s' to match the type of target vector."), targetIsI64?"integer64":type2char(TYPEOF(target)));
898
+
else
899
+
warning(_("Coercing 'character' RHS to '%s' to match the type of column %d named '%s'."), targetIsI64?"integer64":type2char(TYPEOF(target)), colnum, colname);
897
900
// this "Coercing ..." warning first to give context in case coerceVector warns 'NAs introduced by coercion'
898
901
// and also because 'character' to integer/double coercion is often a user mistake (e.g. wrong target column, or wrong
899
902
// variable on RHS) which they are more likely to appreciate than find inconvenient
0 commit comments