Bug 17502 – [REG2.064] Out contract in class method causes dmd segfault.

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-14T11:38:48Z
Last change time
2017-10-01T20:41:07Z
Keywords
pull
Assigned to
No Owner
Creator
drug007

Comments

Comment #0 by drug2004 — 2017-06-14T11:38:48Z
If a method has out contract it causes dmd segfault. ``` class Foo { auto foo() in {} //out {} // uncomment it to get dmd segfault body{} } void main() { auto foo = new Foo(); foo.foo(); } ```
Comment #1 by gassa — 2017-06-14T14:49:40Z
Fails with previous releases, to at least 2.064.2. Between 2.068.2 and 2.069.0 (frontend translated into D), the error diagnostic changes. The "in {}" line can be dropped, but class, auto return type, and "out" without parameters seem to all be important.
Comment #2 by dlang-bugzilla — 2017-06-14T18:29:01Z
Comment #3 by dlang-bugzilla — 2017-06-14T18:41:27Z
Comment #4 by github-bugzilla — 2017-06-15T19:21:38Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/99b7e49ad99ac2cb3e64e053a45e4663271ffae7 Fix issue 17502: Allow no parameters in out contract for auto methods Even in case of non-void methods, their out contract should be able to accept no arguments. For the methods with auto return type, there was oversight where one argument to `out` was always assumed. https://github.com/dlang/dmd/commit/620acd53b63bfede6179a1b6a5c7d1b01a14ed0e Merge pull request #6906 from Burgos/out_param Fix issue 17502: Allow no parameters in out contract for auto methods
Comment #5 by github-bugzilla — 2017-08-07T13:16:45Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/99b7e49ad99ac2cb3e64e053a45e4663271ffae7 Fix issue 17502: Allow no parameters in out contract for auto methods https://github.com/dlang/dmd/commit/620acd53b63bfede6179a1b6a5c7d1b01a14ed0e Merge pull request #6906 from Burgos/out_param
Comment #6 by github-bugzilla — 2017-09-25T21:23:14Z
Commit pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/831552d2047d802c0d4b02c72940ddf43fbc360c Fix bug 17502 (again): Generate contracts after inferring return type. Wait until after the return type has been inferred before generating the contracts for this function, and merging contracts from overrides. This was originally at the end of the first semantic pass, but required a fix-up to be done here for the '__result' variable type of __ensure() inside auto functions, but this didn't work if the out parameter was implicit.
Comment #7 by github-bugzilla — 2017-10-01T20:41:07Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/831552d2047d802c0d4b02c72940ddf43fbc360c Fix bug 17502 (again): Generate contracts after inferring return type.