Compilation failure

Lemonfiend no at email.here
Tue Jul 10 08:17:02 PDT 2012


On Sunday, 8 July 2012 at 22:10:32 UTC, bearophile wrote:
>> When tmp1 is defined globally, dmd is doing something 
>> different, in some way it sees global immutables almost  as 
>> enums... I don't know if this is present in D specs.
>
> You see it well with this test program:
>
>
> immutable int[] A = [1];
> template Foo(size_t n) {}
> void main() {
>     alias Foo!(A.length) fooA; // OK
>     enum int[] B = [1];
>     alias Foo!(B.length) fooB; // OK
>     immutable int[] C = [1];
>     alias Foo!(C.length) fooC; // error
> }
>
>
> Bye,
> bearophile

Thanks for the reply and explanation.

I would never have thought that the declaration scope (local vs 
global) would have such an effect.. Is this specified anywhere?


More information about the Digitalmars-d-learn mailing list