std.range.chain bug?

Jonathan M Davis jmdavisProg at gmx.com
Mon Nov 25 15:44:17 PST 2013


On Monday, November 25, 2013 22:08:37 monarch_dodra wrote:
> On Monday, 25 November 2013 at 21:04:43 UTC, Jesse Phillips wrote:
> > On Monday, 25 November 2013 at 19:38:44 UTC, Jack Applegame
> > 
> > wrote:
> >> This isn't compiles. Bug?
> >> 
> >> import std.range;
> >> class Foo {}
> >> void main() {
> >> 
> >> immutable(Foo)[] a;
> >> immutable(Foo)[] b;
> >> auto c = chain(a, b).length;
> >> 
> >> }
> >> 
> >> http://dpaste.dzfl.pl/71272a10
> > 
> > Seems like a bug to me. If Foo where a string I'd expect it to
> > fail, but what you have looks reasonable.
> 
> Really? Why? As a matter of fact, it *works* with string...

What works with string? chain(a, b).length had better not work if either a or 
b is a string, because hasLength is false for narrow strings.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list