@@ -167,7 +167,10 @@ NULL
167167 }
168168
169169 # Side effect: check scalar
170- if (! is.symbol(j )) {
170+ if (is.symbol(j )) {
171+ # FIXME: as_utf8_character() needs rlang > 0.4.11
172+ j <- chr_unserialise_unicode(as.character(j ))
173+ } else {
171174 if (! is.vector(j ) || length(j ) != 1L || is.na(j ) || (is.numeric(j ) && j < 0 ) || is.logical(j )) {
172175 vectbl_as_col_location2(j , length(x ), j_arg = j_arg , assign = TRUE )
173176 }
@@ -417,11 +420,13 @@ tbl_subassign <- function(x, i, j, value, i_arg, j_arg, value_arg) {
417420
418421 if (is.null(j )) {
419422 j <- seq_along(x )
423+ names(j ) <- names2(j )
420424 } else if (! is.null(j_arg )) {
421425 j <- vectbl_as_new_col_index(j , x , j_arg , names2(value ), value_arg )
422426 }
423427
424428 value <- vectbl_recycle_rhs(value , fast_nrow(x ), length(j ), i_arg = NULL , value_arg )
429+
425430 xo <- tbl_subassign_col(x , j , value )
426431 } else if (is.null(i_arg )) {
427432 # x[NULL, ...] <- value
@@ -488,27 +493,29 @@ vectbl_as_new_row_index <- function(i, x, i_arg) {
488493vectbl_as_new_col_index <- function (j , x , j_arg , names = " " , value_arg = NULL ) {
489494 # Creates a named index vector
490495 # Values: index
491- # Name: column name (for new columns)
496+ # Name: column name (for all columns)
492497
493498 if (is_bare_character(j )) {
494499 if (anyNA(j )) {
495500 cnd_signal(error_assign_columns_non_na_only())
496501 }
497502
498- out <- match(j , names(x ))
499- new <- which(is.na(out ))
503+ names <- j
504+
505+ j <- match(names , names(x ))
506+ new <- which(is.na(j ))
500507 if (has_length(new )) {
501- out [new ] <- seq.int(length(x ) + 1L , length.out = length(new ))
508+ j [new ] <- seq.int(length(x ) + 1L , length.out = length(new ))
502509 }
503- j <- set_names(out , j )
504510 } else if (is_bare_numeric(j )) {
505511 if (anyNA(j )) {
506512 cnd_signal(error_assign_columns_non_na_only())
507513 }
508514
509515 j <- numtbl_as_col_location_assign(j , length(x ), j_arg = j_arg )
510516
511- new <- which(j > length(x ))
517+ old <- (j < = length(x ))
518+ new <- which(! old )
512519 j_new <- j [new ]
513520
514521 if (length(names ) != 1L ) {
@@ -524,20 +531,23 @@ vectbl_as_new_col_index <- function(j, x, j_arg, names = "", value_arg = NULL) {
524531 names [new ][names [new ] == " " ] <- paste0(" ..." , j_new )
525532 }
526533
527- j <- set_names( j , names )
534+ names [ old ] <- names( x )[ j [ old ] ]
528535 } else {
529536 j <- vectbl_as_col_location(j , length(x ), names(x ), j_arg = j_arg , assign = TRUE )
530537
531538 if (anyNA(j )) {
532539 cnd_signal(error_na_column_index(which(is.na(j ))))
533540 }
541+
542+ old <- (j < = length(x ))
543+ names [old ] <- names(x )[ j [old ] ]
534544 }
535545
536546 if (anyDuplicated(j )) {
537547 cnd_signal(error_duplicate_column_subscript_for_assignment(j ))
538548 }
539549
540- j
550+ set_names( j , names )
541551}
542552
543553numtbl_as_row_location_assign <- function (i , n , i_arg ) {
0 commit comments