[Issue 12821] Missed redundant storage class / protection errors.
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 23 18:13:43 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12821
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Iain Buclaw from comment #0)
> Penultimately, the following throw an error unless you specify void. All of
> which seems redundant as there's no return type.
>
> immutable foo() { } // Without 'this' cannot be immutable
> immutable void foo() { } // OK
'immutable' does not modify return type. But in module scope, 'this' qualifier
for non-member function is meaningless and "Without 'this' cannot be immutable"
error occurs in first case. But second case does not raise same error, and it's
inconsistent behavior.
> const foo() { } // Without 'this' cannot be const
> const void foo() { } // OK
> inout foo() { } // Without 'this' cannot be inout
> inout void foo() { } // OK
> shared foo() { } // Without 'this' cannot be shared
> shared void foo() { } // OK
As well, same "Without 'this' cannot be xxx" error should occur in all cases.
To improve compiler behavior, I opened issue 12967.
--
More information about the Digitalmars-d-bugs
mailing list