2.011 invariant question

Walter Bright newshound1 at digitalmars.com
Sun Feb 24 01:12:44 PST 2008


Sönke Ludwig wrote:
> Maybe I'm missing something - but I don't get what's the reasoning 
> behind the
> following error?
> 
> -----------------
> struct FOO {
>     invariant int x;
>     int y;
> }
> 
> int main()
> {
>     FOO bar;
>     bar.y = 2;
>     return 0;
> }
> -----------------
> gives the error:
> test4.d(9): variable test4.main.bar cannot modify struct with immutable 
> members

Compiler bug.



More information about the Digitalmars-d mailing list