Sam Hu wrote: > Originally I posted in learn: > > http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=16913 > > Move here to double confirm whether it is a bug: > static if (isRandomAccessRange!(R) && hasLength!(R)) > ref ElementType!(R) opIndex(uint n) > { > return _input[_input.length - n + 1]; > } > > Shouldn't it be _input.length-(n+1) ? > > Regards, > Sam
Well r[0] would translate to r.opIndex(0) which means it will return r._input[r._input.length - 0 + 1] = r._input[r._input.length + 1] which is outside the array bounds. So yes, it's a bug.