Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 05, 2010 [phobos] phobos commit, revision 2123 | ||||
---|---|---|---|---|
| ||||
phobos commit, revision 2123 user: kyllingstad msg: Bug 5163: meaningless error message with front() applied to void[] It's not possible to index into void[] arrays, which means that they cannot be ranges. Therefore, I've added template constraints to front(), back(), popFront(), and popBack() in std.array that prevents them from being instantiated with void[]. http://www.dsource.org/projects/phobos/changeset/2123 |
November 05, 2010 [phobos] phobos commit, revision 2123 | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsource.org | I noticed something funny when fixing this. In the template constraint
for back(), is(typeof(A.init[0])), is used to check whether the type A
supports indexing. This makes sense. In the constraint for front(),
however, is(typeof(A[0])) is used. Does anyone know why this last case
works at all? Outside of typeof(), A[0] is completely meaningless
unless A is a tuple, so why allow this special case?
-Lars
On Fri, 2010-11-05 at 08:12 -0400, dsource.org wrote:
> phobos commit, revision 2123
>
>
> user: kyllingstad
>
> msg:
> Bug 5163: meaningless error message with front() applied to void[]
>
> It's not possible to index into void[] arrays, which means that they
> cannot be ranges. Therefore, I've added template constraints to
> front(), back(), popFront(), and popBack() in std.array that prevents
> them from being instantiated with void[].
>
> http://www.dsource.org/projects/phobos/changeset/2123
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
November 05, 2010 [phobos] phobos commit, revision 2123 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Tandle Kyllingstad | A[0] is a static array of A's of size 0. However, I'm not sure why it ever passes, because typeof(X) where X is already a type should fail, I think?
-Steve
----- Original Message ----
> From: Lars Tandle Kyllingstad <lars at kyllingen.net>
>
> I noticed something funny when fixing this. In the template constraint
> for back(), is(typeof(A.init[0])), is used to check whether the type A
> supports indexing. This makes sense. In the constraint for front(),
> however, is(typeof(A[0])) is used. Does anyone know why this last case
> works at all? Outside of typeof(), A[0] is completely meaningless
> unless A is a tuple, so why allow this special case?
>
> -Lars
|
November 05, 2010 [phobos] phobos commit, revision 2123 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Schveighoffer | So it's not only weird, it's actually wrong, since A[0] does in fact have a sensible meaning...
Anyway, this shows that the compiler does not interpret it as a static array type inside the typeof():
template Elem(T)
{
alias typeof(T[0]) Elem;
}
static assert (is(Elem!(int[]) == int));
-Lars
On Fri, 2010-11-05 at 06:01 -0700, Steve Schveighoffer wrote:
> A[0] is a static array of A's of size 0. However, I'm not sure why it ever passes, because typeof(X) where X is already a type should fail, I think?
>
> -Steve
>
>
>
> ----- Original Message ----
> > From: Lars Tandle Kyllingstad <lars at kyllingen.net>
> >
> > I noticed something funny when fixing this. In the template constraint
> > for back(), is(typeof(A.init[0])), is used to check whether the type A
> > supports indexing. This makes sense. In the constraint for front(),
> > however, is(typeof(A[0])) is used. Does anyone know why this last case
> > works at all? Outside of typeof(), A[0] is completely meaningless
> > unless A is a tuple, so why allow this special case?
> >
> > -Lars
>
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
Copyright © 1999-2021 by the D Language Foundation