May 20, 2012 Re: How to test for equality of types? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Walter | On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote:
> On 2012-05-19 15:28, Philippe Sigaud wrote:
>> On Sat, May 19, 2012 at 12:23 PM, Matthias Walter
>> <xammy@xammy.homelinux.net> wrote:
>>
>>> I would open a bug report with the following code which is a bit smaller
>>> than my first wrong version:
>>>
>>> =====================
>> (...)
>>> pragma(msg, typeof(w.aliasStruct).Alias.stringof); // -> "MyStruct"
>>> pragma(msg, AliasStruct.Alias.stringof); // -> "MyStruct"
>>> static assert(is(typeof(w.aliasStruct) == AliasStruct)); // -> true
>>> static assert(is(typeof(w.aliasStruct).Alias == AliasStruct.Alias));
>>> // -> false
>>> }
>>
>> Seems like a pb concerning whether Alias is a type or a symbol. See
>> A,B,C,D below:
>>
>> void main()
>> {
>> Wrapper w;
>>
>> pragma(msg, typeof(w.aliasStruct).Alias.stringof); // -> "MyStruct"
>> pragma(msg, AliasStruct.Alias.stringof); // -> "MyStruct"
>> static assert(is(typeof(w.aliasStruct) == AliasStruct)); // -> true
>> static assert(is(w.aliasStruct.Alias == AliasStruct.Alias)); // -> true
>>
>> alias typeof(w.aliasStruct) A; // -> OK
>> //alias typeof(w.aliasStruct).Alias B; // -> NOK
>> //alias A.Alias C; // -> NOK
>> alias w.aliasStruct.Alias D; // -> OK
>>
>> static assert(is(A.Alias == AliasStruct.Alias)); // -> true
>> //static assert(is(B == AliasStruct.Alias));
>> //static assert(is(C == AliasStruct.Alias));
>> static assert(is(D == AliasStruct.Alias)); // -> true
>> }
>>
>> I think A is enough for your need, but I don't get why B and C are not
>> accepted (DMD 2.059, Linux)
>>
>
> Using the current git version of dmd I realized that C works! Hence, as
> a workaround it can be used by creating a local alias A and subsequently
> using A.Alias in the is-expressions. But it seems odd that
>
> "alias typeof(X).A B;" does not work but
> "alias typeof(X) Y; alias Y.A B;" does.
>
> Is this considered as a bug?
>
> Best regards,
>
> Matthias
It seems to me that is a regression by fixing bug 6475.
Now I'm trying to fix them.
|
May 20, 2012 Re: How to test for equality of types? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | On Sunday, 20 May 2012 at 06:57:20 UTC, Kenji Hara wrote: > On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote: >> Using the current git version of dmd I realized that C works! Hence, as >> a workaround it can be used by creating a local alias A and subsequently >> using A.Alias in the is-expressions. But it seems odd that >> >> "alias typeof(X).A B;" does not work but >> "alias typeof(X) Y; alias Y.A B;" does. >> >> Is this considered as a bug? >> >> Best regards, >> >> Matthias > > It seems to me that is a regression by fixing bug 6475. > Now I'm trying to fix them. I've filed the bug in bugzilla: http://d.puremagic.com/issues/show_bug.cgi?id=8123 And posted a pull request to fix it: https://github.com/D-Programming-Language/dmd/pull/957 Thanks. Kenji Hara |
May 21, 2012 Re: How to test for equality of types? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | On Sunday, 20 May 2012 at 06:57:20 UTC, Kenji Hara wrote: > On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote: >> On 2012-05-19 15:28, Philippe Sigaud wrote: >>> On Sat, May 19, 2012 at 12:23 PM, Matthias Walter >>> <xammy@xammy.homelinux.net> wrote: >>> >>>> I would open a bug report with the following code which is a bit smaller >>>> than my first wrong version: >>>> >>>> ===================== >>> (...) >>>> pragma(msg, typeof(w.aliasStruct).Alias.stringof); // -> "MyStruct" >>>> pragma(msg, AliasStruct.Alias.stringof); // -> "MyStruct" >>>> static assert(is(typeof(w.aliasStruct) == AliasStruct)); // -> true >>>> static assert(is(typeof(w.aliasStruct).Alias == AliasStruct.Alias)); >>>> // -> false >>>> } >>> >>> Seems like a pb concerning whether Alias is a type or a symbol. See >>> A,B,C,D below: >>> >>> void main() >>> { >>> Wrapper w; >>> >>> pragma(msg, typeof(w.aliasStruct).Alias.stringof); // -> "MyStruct" >>> pragma(msg, AliasStruct.Alias.stringof); // -> "MyStruct" >>> static assert(is(typeof(w.aliasStruct) == AliasStruct)); // -> true >>> static assert(is(w.aliasStruct.Alias == AliasStruct.Alias)); // -> true >>> >>> alias typeof(w.aliasStruct) A; // -> OK >>> //alias typeof(w.aliasStruct).Alias B; // -> NOK >>> //alias A.Alias C; // -> NOK >>> alias w.aliasStruct.Alias D; // -> OK >>> >>> static assert(is(A.Alias == AliasStruct.Alias)); // -> true >>> //static assert(is(B == AliasStruct.Alias)); >>> //static assert(is(C == AliasStruct.Alias)); >>> static assert(is(D == AliasStruct.Alias)); // -> true >>> } >>> >>> I think A is enough for your need, but I don't get why B and C are not >>> accepted (DMD 2.059, Linux) >>> >> >> Using the current git version of dmd I realized that C works! Hence, as >> a workaround it can be used by creating a local alias A and subsequently >> using A.Alias in the is-expressions. But it seems odd that >> >> "alias typeof(X).A B;" does not work but >> "alias typeof(X) Y; alias Y.A B;" does. >> >> Is this considered as a bug? >> >> Best regards, >> >> Matthias > > It seems to me that is a regression by fixing bug 6475. > Now I'm trying to fix them. Fixed in git head: https://github.com/D-Programming-Language/dmd/commit/76543ef60f3b871612ddc0c87999859f427ba6f9 |
Copyright © 1999-2021 by the D Language Foundation