Thread overview | |||||
---|---|---|---|---|---|
|
May 18, 2008 New template problem | ||||
---|---|---|---|---|
| ||||
After a painful search I have found a new bug in my libs, that comes out using DMD 1.030 (with 1.029 the following code works): template HasLength(T) { // const bool HasLength = is(typeof(T.length)) || is(typeof(T.init.length)); const bool HasLength = is(typeof(T.length)); } void main() { class Foo { int length; } //assert(!HasLength!(typeof( new Foo ))); assert(!HasLength!(typeof( new Foo ))); } Output (DMD 1.030): Error: this for length needs to be type Foo not type int Do you have some workaround/suggestion? Bye, bearophile |
May 19, 2008 Re: New template problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | "bearophile" wrote
> After a painful search I have found a new bug in my libs, that comes out using DMD 1.030 (with 1.029 the following code works):
>
> template HasLength(T) {
> // const bool HasLength = is(typeof(T.length)) ||
> is(typeof(T.init.length));
> const bool HasLength = is(typeof(T.length));
> }
>
> void main() {
> class Foo { int length; }
> //assert(!HasLength!(typeof( new Foo )));
> assert(!HasLength!(typeof( new Foo )));
> }
>
> Output (DMD 1.030):
> Error: this for length needs to be type Foo not type int
>
> Do you have some workaround/suggestion?
Any reason why you use HasLength!(typeof(new Foo)) vs HasLength!(Foo)?
-Steve
|
May 19, 2008 Re: New template problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Steven Schveighoffer:
> Any reason why you use HasLength!(typeof(new Foo)) vs HasLength!(Foo)?
Nope.
(I have reverted to DMD 1.029 because 1.030 doesn't work for me, so I can't tell you if your version too produces the bug).
Bye and thank you,
bearophile
|
Copyright © 1999-2021 by the D Language Foundation