Thread overview
[Issue 12901] `in`/`out` contracts on struct constructor must require function body
Jun 14, 2014
Kenji Hara
[Issue 12901] Assignments to outside members in `in`/`out` contracts shouldn't be allowed
Dec 29, 2017
greenify
Jan 07, 2021
Dlang Bot
June 14, 2014
https://issues.dlang.org/show_bug.cgi?id=12901

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, pull

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/3664

--
June 15, 2014
https://issues.dlang.org/show_bug.cgi?id=12901

--- Comment #2 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/b8a9cad38adb096046b12df5509473118af8436c
fix Issue 12901 - `in`/`out` contracts on struct constructor must require
function body

https://github.com/D-Programming-Language/dmd/commit/1686e60ec81d00d4a1f6fb91a2700d723986034a Merge pull request #3664 from 9rnsr/fix12901

Issue 12901 - `in`/`out` contracts on struct constructor must require function body

--
June 15, 2014
https://issues.dlang.org/show_bug.cgi?id=12901

github-bugzilla@puremagic.com changed:

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

--
December 28, 2017
https://issues.dlang.org/show_bug.cgi?id=12901

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |hsteoh@quickfur.ath.cx
         Resolution|FIXED                       |---

--- Comment #3 from hsteoh@quickfur.ath.cx ---
Broken by https://github.com/dlang/dmd/pull/7527

--
December 28, 2017
https://issues.dlang.org/show_bug.cgi?id=12901

--- Comment #4 from hsteoh@quickfur.ath.cx ---
Arguably, the original fix was invalid: it doesn't stop you from writing:

````
struct S
{
    int a;
    this(int n) in { a = n; } body {} // or do {}
}
````

The problem really is allowing assignment to struct members from inside a contract, which is abuse of the contract feature.  Perhaps the solution should be to enforce purity on the contract, or, less intrusively, make the contract body const (i.e., `this` is const inside the contract body).

--
December 29, 2017
https://issues.dlang.org/show_bug.cgi?id=12901

greenify <greeenify@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greeenify@gmail.com
            Summary|`in`/`out` contracts on     |Assignments to outside
                   |struct constructor must     |members in `in`/`out`
                   |require function body       |contracts shouldn't be
                   |                            |allowed

--
December 30, 2017
https://issues.dlang.org/show_bug.cgi?id=12901

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

https://github.com/dlang/dmd/commit/f8b524688ff2a762b8427d1c673dfb1c53c806f7 Re-fix Issue 12901 in/out contracts on struct constructor must require function body

https://github.com/dlang/dmd/commit/d0a0b9b01a709b6e18151deafbae49a89ea93d9f Merge pull request #7543 from ibuclaw/reg12901

Re-fix Issue 12901 in/out contracts on struct constructor must require function
body
merged-on-behalf-of: Mike Franklin <JinShil@users.noreply.github.com>

--
December 30, 2017
https://issues.dlang.org/show_bug.cgi?id=12901

github-bugzilla@puremagic.com changed:

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

--
January 07, 2021
https://issues.dlang.org/show_bug.cgi?id=12901

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12106 "[dmd-cxx] Implement new syntax for contracts and invariants" was merged into dmd-cxx:

- fe242591c47c2151f787a5b600af9317008da013 by Iain Buclaw:
  [dmd-cxx] Re-fix Issue 12901 in/out contracts on struct constructor must
require function body

https://github.com/dlang/dmd/pull/12106

--