File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -162,11 +162,17 @@ static SEXP EnlargeVector(SEXP x, R_xlen_t newlen)
162162 IS_GROWABLE (x ) &&
163163 XTRUELENGTH (x ) >= newlen ) {
164164 SET_STDVEC_LENGTH (x , newlen );
165- names = getNames (x );
166- if (!isNull (names )) {
167- SEXP newnames = EnlargeNames (names , len , newlen );
168- if (names != newnames )
169- setAttrib (x , R_NamesSymbol , newnames );
165+ if (ATTRIB (x ) != R_NilValue ) {
166+ names = getNames (x );
167+ if (!isNull (names )) {
168+ SEXP newnames = EnlargeNames (names , len , newlen );
169+ if (names != newnames )
170+ setAttrib (x , R_NamesSymbol , newnames );
171+ }
172+ if (getAttrib (x , R_DimSymbol ) != R_NilValue )
173+ setAttrib (x , R_DimSymbol , R_NilValue );
174+ if (getAttrib (x , R_DimNamesSymbol ) != R_NilValue )
175+ setAttrib (x , R_DimNamesSymbol , R_NilValue );
170176 }
171177 return x ;
172178 }
Original file line number Diff line number Diff line change @@ -2342,6 +2342,15 @@ stopifnot(exprs = { ## logical/numeric mixtures:
23422342 }
23432343})
23442344
2345+ # # check that tim and dimnames are dropped when estending with GROWABLE
2346+ x <- 1 : 49
2347+ x [50 ] <- 50L
2348+ dim(x ) <- c(25 , 2 )
2349+ dimnames(x ) <- list (NULL , c(" a" , " b" ))
2350+ a <- .Internal(address(x ))
2351+ x [51 ] <- 51L
2352+ stopifnot(identical(a , .Internal(address(x )))) # # reused x
2353+ stopifnot(is.null(attributes(x ))) # # dim and dimnames have been dropped
23452354
23462355
23472356# # keep at end
You can’t perform that action at this time.
0 commit comments