Commit d6086347 authored by Radford Neal's avatar Radford Neal

bug fix re [[ on arrays with 4 or more indexes, new test

parent 221e9c20
......@@ -4807,10 +4807,10 @@ SEXP attribute_hidden do_subassign2_dflt_int
ix = sb1;
else if (i == 1)
ix = sb2;
else {
else if (i == 2)
ix = CAR(s);
s = CDR(s);
}
else
ix = CAR(nthcdr(s,i-2));
R_len_t ii =
get1index(ix, names==R_NilValue ? R_NilValue : VECTOR_ELT(names,i),
INTEGER(dims)[i], /*partial ok*/ FALSE, -1, call);
......
......@@ -286,3 +286,20 @@ stopifnot(identical(A[_,2],c(a=3)))
A <- M[_,1..1]
stopifnot(identical(A[2,],3))
stopifnot(identical(A[2,_],c(x=3)))
# Check array indexing.
a <- array(1:120,c(2,3,4,5))
a[2,3,4,5] <- 9999L
stopifnot(a[2,3,4,5]==9999L)
stopifnot(a[length(a)]==9999L)
a[2,3,4,5] <- 120L
stopifnot(all(c(a)==1:120))
a <- array(1:120,c(2,3,4,5))
a[[2,3,4,5]] <- 9999L
stopifnot(a[[2,3,4,5]]==9999L)
stopifnot(a[length(a)]==9999L)
a[[2,3,4,5]] <- 120L
stopifnot(all(c(a)==1:120))
pqR version 2.15.1 (2017-00-00), based on R 2.15.0 (2012-03-30)
pqR version 2.15.1 (2018-00-00), based on R 2.15.0 (2012-03-30)
R 2.15.0 is Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Modifications to R in pqR are Copyright (C) 2013-2017 Radford M. Neal
Modifications to R in pqR are Copyright (C) 2013-2018 Radford M. Neal
Some modules are from R-2.15.1 or later versions distributed by the R Core Team
Platform: x86_64-unknown-linux-gnu (64-bit)
Platform: x86_64-apple-darwin17.7.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
......@@ -23,7 +23,7 @@ Type 'demo()' for some demos, 'help()' for on-line help, or
Type 'q()' to quit R.
1 helper threads, task merging enabled, uncompressed pointers.
No helper threads, task merging enabled, uncompressed pointers.
> # Test possible bugs involving subset and subassign.
> #
......@@ -315,3 +315,20 @@ DONE
> stopifnot(identical(A[2,],3))
> stopifnot(identical(A[2,_],c(x=3)))
>
>
> # Check array indexing.
>
> a <- array(1:120,c(2,3,4,5))
> a[2,3,4,5] <- 9999L
> stopifnot(a[2,3,4,5]==9999L)
> stopifnot(a[length(a)]==9999L)
> a[2,3,4,5] <- 120L
> stopifnot(all(c(a)==1:120))
>
> a <- array(1:120,c(2,3,4,5))
> a[[2,3,4,5]] <- 9999L
> stopifnot(a[[2,3,4,5]]==9999L)
> stopifnot(a[length(a)]==9999L)
> a[[2,3,4,5]] <- 120L
> stopifnot(all(c(a)==1:120))
>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment