http://d.puremagic.com/issues/show_bug.cgi?id=2521


yebblies <yebbl...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
                 CC|                            |yebbl...@gmail.com


--- Comment #5 from yebblies <yebbl...@gmail.com> 2011-06-07 04:22:52 PDT ---
This bug addresses two issues.

This does not currently work:

-------------------------------

immutable int val = 23;

ref immutable(int) func()
{
    return val;
}


Error: constant 23 is not an lvalue
-------------------------------

And this gives the same terrible error message:

-------------------------------

immutable int val = 23;

ref int func()
{
    return val;
}

Error: constant 23 is not an lvalue
-------------------------------

The proposed fix (dmd pull 92) allows the first case, and changes the error to
the following for the second case:

Error: cast(int)val is not an lvalue

The root cause of this bug is the fact that while running semantic on the
return expression, the immutable variable's value is known at compile time, and
is optimized without checking if the function returns an lvalue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to