Comment #4 by bearophile_hugs — 2014-06-16T15:41:23Z
Currently this gets rejected, is this right?
void main() @nogc {
foreach ( a; [[1]]) {}
foreach (int[1] a; [[1]]) {}
}
test.d(2): Error: array literal in @nogc function main may cause GC allocation
test.d(3): Error: array literal in @nogc function main may cause GC allocation
Comment #5 by bearophile_hugs — 2014-06-16T15:46:53Z
A better example:
struct F { int x; }
void main() @nogc {
foreach ( a; [[1]]) {} // Error
foreach (int[1] a; [[1]]) {} // Error
foreach ( a; [F(1)]) {} // OK
}
Comment #6 by k.hara.pg — 2014-06-16T16:10:34Z
(In reply to bearophile_hugs from comment #4)
> Currently this gets rejected, is this right?
>
> void main() @nogc {
> foreach ( a; [[1]]) {}
> foreach (int[1] a; [[1]]) {}
> }
>
>
> test.d(2): Error: array literal in @nogc function main may cause GC
> allocation
> test.d(3): Error: array literal in @nogc function main may cause GC
> allocation
My PR does not support complex case. It would need more thought to improve the feature.
Comment #7 by bearophile_hugs — 2014-06-16T16:44:16Z
(In reply to Kenji Hara from comment #6)
> My PR does not support complex case. It would need more thought to improve
> the feature.
OK. Do you want me to open another enhancement request, or do you want me to reopen this one, or do you think this improved feature is not worth implementing?
Comment #8 by k.hara.pg — 2014-06-16T16:48:57Z
(In reply to bearophile_hugs from comment #7)
> OK. Do you want me to open another enhancement request, or do you want me to
> reopen this one, or do you think this improved feature is not worth
> implementing?
If possible, I'd like to improve things. But it would need more time. Therefore openeng new encancement is the best.
Comment #9 by bearophile_hugs — 2014-06-16T16:59:25Z
(In reply to Kenji Hara from comment #8)
> (In reply to bearophile_hugs from comment #7)
> > OK. Do you want me to open another enhancement request, or do you want me to
> > reopen this one, or do you think this improved feature is not worth
> > implementing?
>
> If possible, I'd like to improve things. But it would need more time.
> Therefore openeng new encancement is the best.
OK, Issue 12936