Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
August 30, 2010 Re: Problems with receive | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Sun, Aug 29, 2010 at 10:45 AM, Bob Cowdery <bob@bobcowdery.plus.com>wrote: > > Error: static assert "function with arguments (VariantN!(maxSize)) > occludes successive function" > But there is no successive function, its the last statement. > > I encountered this one too and it appears to be a regression in 2.048 that did not occur in 2.047. It's the same msg[0] vs. msg.field[0] problem, but in concurrency.d itself. It's a one line patch to make this work. In /usr/include/d/dmd/phobos/std/concurrency.d, change line 384 to look like this: static assert( a1.length != 1 || !is( a1.field[0] == Variant ), |
August 30, 2010 Re: Problems with receive | ||||
---|---|---|---|---|
| ||||
30.08.2010 3:06, SK wrote:
> On Sun, Aug 29, 2010 at 10:45 AM, Bob Cowdery <bob@bobcowdery.plus.com <mailto:bob@bobcowdery.plus.com>> wrote:
>
>
> Error: static assert "function with arguments (VariantN!(maxSize))
> occludes successive function"
> But there is no successive function, its the last statement.
>
>
> I encountered this one too and it appears to be a regression in 2.048 that did not occur in 2.047. It's the same msg[0] vs. msg.field[0] problem, but in concurrency.d itself. It's a one line patch to make this work.
>
> In /usr/include/d/dmd/phobos/std/concurrency.d, change line 384 to look like this:
>
> static assert( a1.length != 1 || !is( a1.field[0] == Variant ),
Is that so? I thought ParameterTypeTuple and Tuple are different.
|
August 30, 2010 Re: Problems with receive | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Mon, Aug 30, 2010 at 12:23, Stanislav Blinov <blinov@loniir.ru> wrote: > 30.08.2010 3:06, SK wrote: > > I encountered this one too and it appears to be a regression in 2.048 that >> did not occur in 2.047. It's the same msg[0] vs. msg.field[0] problem, but in concurrency.d itself. It's a one line patch to make this work. >> >> In /usr/include/d/dmd/phobos/std/concurrency.d, change line 384 to look like this: >> >> static assert( a1.length != 1 || !is( a1.field[0] == Variant ), >> > > Is that so? I thought ParameterTypeTuple and Tuple are different. > You're right, there are different. ParameterTypeTuple is a type tuple (a bunch of types grouped together, with indexing and length, like an array). Tuple is a struct wrapping a type tuple, which can be exposed through the .field member. In the above line, since a1 is a ParameterTypeTuple, it has no .field member. In effect the expression a1.field[0] == Variant has no meaningful type and so is(...) is always false. Hence, || !is(...) is like || true. It disables the second part of the test. As for std.concurrency, I never looked at the code before, but the point of receive() seems to do compile-time checking on the matching functions before calling mbox.get( ops ), it's a good idea to put make the if statement a static if: all other constructs in there are done compile-time, I'd guess. Philippe |
August 30, 2010 Re: Problems with receive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Philippe Sigaud | Philippe Sigaud wrote: > static assert( a1.length != 1 || !is( a1.field[0] == Variant ), > > > > Is that so? I thought ParameterTypeTuple and Tuple are different. > > > You're right, there are different. ParameterTypeTuple is a type tuple (a bunch of types grouped together, with indexing and length, like an array). Tuple is a struct wrapping a type tuple, which can be exposed through the .field member. > > In the above line, since a1 is a ParameterTypeTuple, it has no .field member. In effect the expression a1.field[0] == Variant has no meaningful type and so is(...) is always false. Hence, || !is(...) is like || true. It disables the second part of the test. Thanks, I thought I'm at a loss. > > As for std.concurrency, I never looked at the code before, but the point of receive() seems to do compile-time checking on the matching functions before calling mbox.get( ops ), it's a good idea to put make the if statement a static if: all other constructs in there are done compile-time, I'd guess. Yes, that's it. And one (final from me :) ) proposed fix for current Phobos would be this: The mentioned line (384) of std.concurrency should read: static assert( !T[i+1..$].length || a1.length != 1 || !is( a1[0] == Variant ), The error occurs currently because function parameter is enforced NOT to be a Variant even for last function in the list (because of i < T.length on line 382). Thus, assert triggers no matter where in receive() do you insert a Variant handler. Proposed workaround should overcome this by adding additional condition that currently examined handler is not the last one in the list. |
August 30, 2010 Re: Problems with receive | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov Attachments:
| On Mon, Aug 30, 2010 at 1:21 PM, Stanislav Blinov < stanislav.blinov@gmail.com> wrote:
> Philippe Sigaud wrote:
>
>> static assert( a1.length != 1 || !is( a1.field[0] == Variant ),
>>
>>
>> Is that so? I thought ParameterTypeTuple and Tuple are different.
>>
>>
>> You're right, there are different. ParameterTypeTuple is a type tuple (a bunch of types grouped together, with indexing and length, like an array). Tuple is a struct wrapping a type tuple, which can be exposed through the .field member.
>>
>> In the above line, since a1 is a ParameterTypeTuple, it has no .field member. In effect the expression a1.field[0] == Variant has no meaningful type and so is(...) is always false. Hence, || !is(...) is like || true. It disables the second part of the test.
>>
>
> Thanks, I thought I'm at a loss.
>
>
>
>> As for std.concurrency, I never looked at the code before, but the point of receive() seems to do compile-time checking on the matching functions before calling mbox.get( ops ), it's a good idea to put make the if statement a static if: all other constructs in there are done compile-time, I'd guess.
>>
>
> Yes, that's it. And one (final from me :) ) proposed fix for current Phobos
> would be this:
>
> The mentioned line (384) of std.concurrency should read:
>
> static assert( !T[i+1..$].length || a1.length != 1 || !is( a1[0] == Variant
> ),
>
> The error occurs currently because function parameter is enforced NOT to be a Variant even for last function in the list (because of i < T.length on line 382). Thus, assert triggers no matter where in receive() do you insert a Variant handler. Proposed workaround should overcome this by adding additional condition that currently examined handler is not the last one in the list.
>
>
Thank you guys. I see that I am too dangerous with .field
|
Copyright © 1999-2021 by the D Language Foundation