please help me submit a bug!

Basile B. b2.temp at gmx.com
Fri Oct 8 14:42:08 UTC 2021


On Friday, 8 October 2021 at 14:01:40 UTC, workman wrote:
> I can not finish the register some how.
>
> The problem is there is no easy way to find which line cause 
> this error:
>
> Error: array literal in `@nogc` function 
> `app.test.updateBy!("updated_at", "counter").updateBy` may 
> cause a GC allocation
>
>
> This function is huge, I hope compiler can print the the lines.
>
> I test on LDC2 1.28.0-beta1

Why do you think that there is a bug ?

D array literals are dynamic arrays, so the GC is used.

If the function in which resides the call to `updateBy` is 
`@nogc` then it is probable that `updateBy` becomes `@nogc` by 
attribute inference, except that it cant because of the array 
literal.

Possible workaround: if the array literal contains simple values 
that are known at compile time try to declare it `static 
immutable`.





More information about the Digitalmars-d mailing list