Skip to content

Commit

Permalink
amend 73758: <NULL>[.] <- <length 0> should work
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@73773 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Nov 22, 2017
1 parent d41d2e1 commit 7124a84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/subassign.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1997-2017 The R Core Team
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1608,7 +1608,7 @@ SEXP attribute_hidden do_subassign_dflt(SEXP call, SEXP op, SEXP args, SEXP rho)
PROTECT(x = PairToVectorList(x));
}
else if (xlength(x) == 0) {
if (xlength(y) == 0 && TYPEOF(x) == TYPEOF(y)) {
if (xlength(y) == 0 && (isNull(x) || TYPEOF(x) == TYPEOF(y))) {
UNPROTECT(1);
return(x);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/reg-tests-1d.R
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,10 @@ stopifnot(identical(x0, character()), identical(x1, x0), identical(x, n0))
## x0, x1 had remained 'numeric()' in R <= 3.4.x
x[1] <- numeric(); stopifnot(identical(x, n0))
## had always worked; just checking
NUL <- NULL
NUL[3] <- integer(0); NUL[,2] <- character() ; NUL[3,4,5] <- list()
stopifnot(is.null(NUL))
## had failed for a few days in R-devel



Expand Down

0 comments on commit 7124a84

Please sign in to comment.