169169 # Side effect: check scalar
170170 if (! is.symbol(j )) {
171171 if (! is.vector(j ) || length(j ) != 1L || is.na(j ) || (is.numeric(j ) && j < 0 ) || is.logical(j )) {
172- vectbl_as_col_location2(j , length(x ) + 1L , j_arg = j_arg , assign = TRUE )
172+ vectbl_as_col_location2(j , length(x ), j_arg = j_arg , assign = TRUE )
173173 }
174174 }
175175
178178 # New columns are added to the end, provide index to avoid matching column
179179 # names again
180180 value <- list (value )
181- names(value ) <- names(j )
182181
183- tbl_subassign(x , i , j , value , i_arg = i_arg , j_arg = j_arg , value_arg = value_arg )
182+ # j is already pretty
183+ tbl_subassign(x , i , j , value , i_arg = i_arg , j_arg = NULL , value_arg = value_arg )
184184}
185185
186186
@@ -449,8 +449,6 @@ tbl_subassign <- function(x, i, j, value, i_arg, j_arg, value_arg) {
449449 # Fill up columns if necessary
450450 if (has_length(new )) {
451451 init <- map(value [new ], vec_slice , rep(NA_integer_ , fast_nrow(x )))
452- names(init ) <- coalesce2(names2(j )[new ], names2(value )[new ])
453-
454452 x <- tbl_subassign_col(x , j [new ], init )
455453 }
456454
@@ -603,7 +601,7 @@ tbl_subassign_col <- function(x, j, value) {
603601 new <- which(j > length(x ))
604602 if (has_length(new )) {
605603 length(x ) <- max(j [new ])
606- names(x )[ j [new ] ] <- coalesce2( names2(j )[new ], names2( value )[ new ])
604+ names(x )[ j [new ] ] <- names2(j )[new ]
607605 }
608606
609607 # Update
@@ -620,12 +618,6 @@ tbl_subassign_col <- function(x, j, value) {
620618 set_tibble_class(x , nrow )
621619}
622620
623- coalesce2 <- function (x , y ) {
624- use_y <- which(is.na(x ))
625- x [use_y ] <- y [use_y ]
626- x
627- }
628-
629621tbl_expand_to_nrow <- function (x , i ) {
630622 nrow <- fast_nrow(x )
631623
0 commit comments