Another purity question

Timon Gehr timon.gehr at gmx.ch
Tue Jan 14 12:36:42 PST 2014


On 01/14/2014 08:50 PM, bearophile wrote:
> Currently D refuses code like this:
>
>
> void foo(const int[] a) {
>      int bar() pure {
>          return a[0];
>      }
> }
> void main() {}
>
>
> With two repeated error messages:
>
> test1.d(3): Error: pure nested function 'bar' cannot access mutable data
> 'a'
> test1.d(3): Error: pure nested function 'bar' cannot access mutable data
> 'a'
>
>
> But is it possible for D to see that bar function as pure?
>
> Bye,
> bearophile

Yes, it should.

https://d.puremagic.com/issues/show_bug.cgi?id=9148


More information about the Digitalmars-d-learn mailing list