2 problems I can't get my head around

Walter Bright newshound2 at digitalmars.com
Mon Nov 26 13:18:16 PST 2012


On 11/27/2012 1:36 AM, jerro wrote:
>> That doesn't work, immutable breaks that test.
>
> You're right. I didn't expect that. It seems that this compiles:
>
> void foo()
> {
>      immutable a = 1;
>      enum b = a;
> }
>
> But this doesn't, obviously:
>
> void foo(immutable int a)
> {
>      enum b = a;
> }
>
> I wonder, is this considered a bug? It seems very inconsistent to me.

It's not a bug. In  the latter case, b is a manifest constant, and its 
value cannot be determined at compile time. Hence, it will not compile.


More information about the Digitalmars-d mailing list