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 #6 by github-bugzilla — 2017-09-25T21:23:14Z
Commit pushed to stable at https://github.com/dlang/dmdhttps://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