Jump to page: 1 2
Thread overview
[Issue 10326] Disallow 'invariant' for immutable, allow class/struct invariants without (), and later disallow usage of ()
May 09, 2014
Kenji Hara
May 10, 2014
Kenji Hara
May 12, 2014
Temtaime
May 17, 2014
Kenji Hara
May 17, 2014
Temtaime
May 17, 2014
Kenji Hara
May 17, 2014
Temtaime
May 17, 2014
yebblies
Dec 17, 2022
Iain Buclaw
May 09, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |temtaime@gmail.com

--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> ---
*** Issue 12718 has been marked as a duplicate of this issue. ***

--
May 10, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
Remove errors and accept the syntax `invariant { ... }` for declaring invariant
block.
https://github.com/D-Programming-Language/dmd/pull/3540

--
May 12, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
May 12, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7cbb9a48ac7b9ea6c14ea859bc40dbc35e932e0c
fix Issue 10326 - Disallow 'invariant' for immutable, allow class/struct
invariants without (), and later disallow usage of ()

https://github.com/D-Programming-Language/dmd/commit/6f08c339d574bb3d808f40ea965f29caa433c000 Merge pull request #3540 from 9rnsr/fix10326

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

--
May 12, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

--- Comment #6 from bearophile_hugs@eml.cc ---
I'd like to reopen this issue because it's not done yet. The last missing step
is to (in future) give an error in line 2 of program, disallowing the () after
invariant:


struct Foo {
    invariant() {
        assert(false);
    }
    void bar() {}
}
unittest() {} // Not allowed.
void main() {
    Foo f;
    f.bar;
}

--
May 12, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #7 from bearophile_hugs@eml.cc ---
Reopened. Waiting for opinions.

--
May 12, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

--- Comment #8 from Temtaime <temtaime@gmail.com> ---
I agree () should give deprecation for now and error in future.

--
May 17, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to bearophile_hugs from comment #6)
> I'd like to reopen this issue because it's not done yet. The last missing
> step is to (in future) give an error in line 2 of program, disallowing the
> () after invariant:
> 
> 
> struct Foo {
>     invariant() {
>         assert(false);
>     }
>     void bar() {}
> }
> unittest() {} // Not allowed.
> void main() {
>     Foo f;
>     f.bar;
> }

Instead of that, how about to accept both invariant(){...}  and unittest(){...}
?

--
May 17, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

--- Comment #10 from Temtaime <temtaime@gmail.com> ---
@Kenji it's useless imo.

--
May 17, 2014
https://issues.dlang.org/show_bug.cgi?id=10326

--- Comment #11 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to Temtaime from comment #10)
> @Kenji it's useless imo.

My main concern is, that disallowing current invariant() syntax will break many existing D2 code. I'm afraid to decrease language stability.

On the other hand, accepting the syntax `unittest(){...}` would not have any design benefit, but it will increase syntax consistency.

--
« First   ‹ Prev
1 2