static foreach @nogc

Jacob Carlborg doob at me.com
Thu May 30 15:02:44 UTC 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


More information about the Digitalmars-d mailing list