Skip to content

Commit c97dbd1

Browse files
author
maechler
committed
is.atomic(NULL) now is FALSE
git-svn-id: https://svn.r-project.org/R/trunk@85227 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent b1ca1a7 commit c97dbd1

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

doc/NEWS.Rd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
32-bit platforms will still report \code{(32-bit)}.
1515

1616
On Windows, ditto for window titles.
17+
18+
\item \code{is.atomic(NULL)} now returns \code{FALSE}, as \code{NULL}
19+
is not an atomic vector. Strict back compatibility would
20+
replace \code{is.atomic(foo)} by \code{(is.null(foo) || is.atomic(foo))}
21+
but should happen sparingly only.
1722
}
1823
}
1924

src/main/coerce.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,8 +2064,10 @@ attribute_hidden SEXP do_is(SEXP call, SEXP op, SEXP args, SEXP rho)
20642064

20652065
case 200: /* is.atomic */
20662066
switch(TYPEOF(CAR(args))) {
2067+
#ifdef S_compatible_BUT_UNDESIRABLE
20672068
case NILSXP:
20682069
/* NULL is atomic (S compatibly), but not in isVectorAtomic(.) */
2070+
#endif
20692071
case CHARSXP:
20702072
case LGLSXP:
20712073
case INTSXP:

tests/demos.Rout.save

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ Number of functions from these: 1347
338338

339339
> is.ALL(NULL)
340340
is.array : .
341-
is.atomic : |
341+
is.atomic : .
342342
is.call : .
343343
is.character : .
344344
is.complex : .
@@ -349,15 +349,15 @@ is.expression : .
349349
is.factor : .
350350
is.finite : NA
351351
is.function : .
352-
is.infinite :
352+
is.infinite : NA
353353
is.integer : .
354354
is.language : .
355355
is.list : .
356356
is.logical : .
357357
is.matrix : .
358358
is.na : NA
359359
is.name : .
360-
is.nan :
360+
is.nan : NA
361361
is.null : |
362362
is.numeric : .
363363
is.numeric_version : .
@@ -375,7 +375,7 @@ is.vector : .
375375

376376
> ##fails: is.ALL(NULL, not.using = c("is.single", "is.loaded"))
377377
> is.ALL(NULL, true.only = TRUE)
378-
[1] "is.atomic" "is.null" "is.pairlist"
378+
[1] "is.null" "is.pairlist"
379379

380380
> all.equal(NULL, pairlist())
381381
[1] TRUE

tests/reg-tests-1e.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ stopifnot(exprs = {
857857
## negative integer scalars
858858
tools::assertWarning(compiler::cmpfun(function(x) sqrt(x))(-1L))
859859

860-
860+
## is.atomic(NULL) is no longer true
861+
if(is.atomic(NULL)) stop("Should no longer happen: 'NULL' is not atomic")
861862
## untested previously
862863
stopifnot(is.null(sort(NULL)), is.null(sort.int(NULL)))
863864
## failed in first version of `R-is` branch

0 commit comments

Comments
 (0)