Skip to content

Commit 4f168e6

Browse files
committed
more informative error in case of excess index
1 parent e5facae commit 4f168e6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2018-11-11 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/vector/Subsetter.h (check_indices): More
4+
informative error message as suggested by KK
5+
16
2018-11-09 William Nolan <[email protected]>
27

38
* inst/include/Rcpp/vector/Subsetter.h: Fixed to use R_xlen_t instead

inst/include/Rcpp/vector/Subsetter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SubsetProxy {
6767
stop("index error");
6868
}
6969
return *this;
70-
}
70+
}
7171

7272
// Enable e.g. x[y] = 1;
7373
// TODO: std::enable_if<primitive> with C++11
@@ -139,7 +139,7 @@ class SubsetProxy {
139139
for (IDX i=0; i < n; ++i) {
140140
if (x[i] < 0 or x[i] >= size) {
141141
if(std::numeric_limits<IDX>::is_integer && size > std::numeric_limits<IDX>::max()) {
142-
stop("use NumericVector to index an object of this size");
142+
stop("use NumericVector to index an object of length %td", size);
143143
}
144144
stop("index error");
145145
}
@@ -157,7 +157,7 @@ class SubsetProxy {
157157
for (R_xlen_t i=0; i < rhs_n; ++i) {
158158
indices.push_back( rhs[i] );
159159
}
160-
indices_n = rhs_n;
160+
indices_n = rhs_n;
161161
}
162162

163163
void get_indices( traits::identity< traits::int2type<REALSXP> > t ) {

0 commit comments

Comments
 (0)