D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17502 - [REG2.064] Out contract in class method causes dmd segfault.
Summary: [REG2.064] Out contract in class method causes dmd segfault.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 regression
Assignee: No Owner
URL: http://dlang.org/
Keywords: pull
Depends on:
Blocks:
 
Reported: 2017-06-14 11:38 UTC by drug007
Modified: 2017-10-01 20:41 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description drug007 2017-06-14 11:38:48 UTC
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 Ivan Kazmenko 2017-06-14 14:49:40 UTC
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 Vladimir Panteleev 2017-06-14 18:29:01 UTC
Introduced in https://github.com/dlang/dmd/pull/2383
Comment 3 Vladimir Panteleev 2017-06-14 18:41:27 UTC
PR by @Burgos:
https://github.com/dlang/dmd/pull/6906
Comment 4 github-bugzilla 2017-06-15 19:21:38 UTC
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 github-bugzilla 2017-08-07 13:16:45 UTC
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 github-bugzilla 2017-09-25 21:23:14 UTC
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 github-bugzilla 2017-10-01 20:41:07 UTC
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.