Thread overview
static foreach @nogc
May 30, 2019
Exil
May 30, 2019
rikki cattermole
May 30, 2019
Jacob Carlborg
May 30, 2019
Timon Gehr
Jun 04, 2019
Jacob Carlborg
Jun 05, 2019
Timon Gehr
May 30, 2019
Dennis
May 31, 2019
Nicholas Wilson
Jun 05, 2019
Timon Gehr
May 30, 2019
Am I missing something or should this be able to compile? I don't know where it is even using ~=, is it used internally for ranges?

struct T
{
@nogc:

auto opBinary(string op, V)(auto ref const(V) vec) const
{
    // Error: cannot use operator ~= in @nogc delegate onlineapp.T.opBinary!("+", T).opBinary.__lambda2
    static foreach(i ; 0 .. 1)
    {
    }
    return this;
}
}

void main() {
    T a, b;
    T c = a + b;
}


https://run.dlang.io/is/JDXcJj
May 30, 2019
Bug report please. That shouldn't be happening.
May 30, 2019
On 2019-05-30 04:56, Exil wrote:
> 
> Am I missing something or should this be able to compile? I don't know where it is even using ~=, is it used internally for ranges?
> 
> struct T
> {
> @nogc:
> 
> auto opBinary(string op, V)(auto ref const(V) vec) const
> {
>      // Error: cannot use operator ~= in @nogc delegate onlineapp.T.opBinary!("+", T).opBinary.__lambda2
>      static foreach(i ; 0 .. 1)
>      {
>      }
>      return this;
> }
> }
> 
> void main() {
>      T a, b;
>      T c = a + b;
> }
> 
> 
> https://run.dlang.io/is/JDXcJj

Looks like there are two issues here:

1. That "static foreach" cannot be used in a @nogc function
2. That the error message mentions "delegate", which are not in the source code

-- 
/Jacob Carlborg
May 30, 2019
On Thursday, 30 May 2019 at 02:56:16 UTC, Exil wrote:
> Am I missing something or should this be able to compile?

It's a known bug: https://issues.dlang.org/show_bug.cgi?id=18439
May 30, 2019
On 30.05.19 17:02, Jacob Carlborg wrote:
> On 2019-05-30 04:56, Exil wrote:
>>
>> Am I missing something or should this be able to compile? I don't know where it is even using ~=, is it used internally for ranges?
>>
>> struct T
>> {
>> @nogc:
>>
>> auto opBinary(string op, V)(auto ref const(V) vec) const
>> {
>>      // Error: cannot use operator ~= in @nogc delegate onlineapp.T.opBinary!("+", T).opBinary.__lambda2
>>      static foreach(i ; 0 .. 1)
>>      {
>>      }
>>      return this;
>> }
>> }
>>
>> void main() {
>>      T a, b;
>>      T c = a + b;
>> }
>>
>>
>> https://run.dlang.io/is/JDXcJj
> 
> Looks like there are two issues here:
> 
> 1. That "static foreach" cannot be used in a @nogc function
> 2. That the error message mentions "delegate", which are not in the source code
> 

The only issue here is that `@nogc:` applies to all nested functions, including delegates that are only used for CTFE.
May 31, 2019
On Thursday, 30 May 2019 at 15:11:31 UTC, Dennis wrote:
> On Thursday, 30 May 2019 at 02:56:16 UTC, Exil wrote:
>> Am I missing something or should this be able to compile?
>
> It's a known bug: https://issues.dlang.org/show_bug.cgi?id=18439

Fixed in https://github.com/dlang/dmd/pull/9922
June 04, 2019
On 2019-05-30 17:29, Timon Gehr wrote:

> The only issue here is that `@nogc:` applies to all nested functions, including delegates that are only used for CTFE.

You don't see it has a problem that the compiler mentions "delegate" in an error message but "delegate" doesn't exist in the source code?

-- 
/Jacob Carlborg
June 06, 2019
On 04.06.19 19:58, Jacob Carlborg wrote:
> On 2019-05-30 17:29, Timon Gehr wrote:
> 
>> The only issue here is that `@nogc:` applies to all nested functions, including delegates that are only used for CTFE.
> 
> You don't see it has a problem that the compiler mentions "delegate" in an error message but "delegate" doesn't exist in the source code?
> 

The problem is that there is an error message at all.
June 06, 2019
On 31.05.19 05:40, Nicholas Wilson wrote:
> On Thursday, 30 May 2019 at 15:11:31 UTC, Dennis wrote:
>> On Thursday, 30 May 2019 at 02:56:16 UTC, Exil wrote:
>>> Am I missing something or should this be able to compile?
>>
>> It's a known bug: https://issues.dlang.org/show_bug.cgi?id=18439
> 
> Fixed in https://github.com/dlang/dmd/pull/9922

Disgusting.