[Issue 10326] Disallow 'invariant' for immutable, allow class/struct invariants without (), and later disallow usage of ()

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat May 17 17:09:06 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=10326

briancschott at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |briancschott at gmail.com
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=5038

--- Comment #15 from briancschott at gmail.com ---
(In reply to bearophile_hugs from comment #13)
> (In reply to Kenji Hara from comment #9)
> 
> > Instead of that, how about to accept both invariant(){...}  and
> > unittest(){...} ?
> 
> I prefer to disallow () in both.

I vote for this also. The parenthesis serve no purpose. The compiler should
accept () with a deprecation message and then we should get rid of them.

Quoting from bug 5038:

"Well, this is a very strange situation. invariant without parentheses is LEGAL
IN D1! When converting D1 code to D2, you get this nonsense deprecation message
asking you to use immutable instead.

We have existing production code which uses invariant without parentheses!
We should make it legal again. This would be an undeprecation, which AFAIK has
never happened before in D."

--


More information about the Digitalmars-d-bugs mailing list