http://d.puremagic.com/issues/show_bug.cgi?id=4734
Jonathan M Davis <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Jonathan M Davis <[email protected]> 2010-08-26 14:44:23 PDT --- Unfortunately, this is not a bug. Putting either const or immutable on a function - be it on the left of the function signature or the right - makes that function immutable. If you want the return type to be const or immutable, you _must_ use parens. As I understand it, this was done to make const and immutable work the sames as modifiers like private, public, pure, and nothrow (which mean the same thing regardless of which side of the function that they're on). A number of use would like const and immutable to have to be on the right if you want to make the function const or immutable, but Walter doesn't agree, so it doesn't work that way. So, your function declaration is making the function immutable, _not_ the return type. The reason why using const with your unit test works but immutable does not is because both mutable and immutable values can be used with const functions, but only immutable ones can be used with immutable functions. immutable test = new Test; test.foo(); should work just fine with the way that you declared the function. Now, I think that the error message definitely needs some work; it should indicate that the variable needs to be immutable rather than talking about the function arguments (it's probably doing that because the this pointer is an invisible function argument), but it is essentially correct. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
