Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 17502: Allow no parameters in out contract for auto methods #6906

Merged
merged 1 commit into from
Jun 15, 2017

Conversation

Burgos
Copy link
Member

@Burgos Burgos commented Jun 14, 2017

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.

@dlang-bot
Copy link
Contributor

dlang-bot commented Jun 14, 2017

Fix Bugzilla Description
17502 [REG2.064] Out contract in class method causes dmd segfault.

@MetaLang
Copy link
Member

It may be worth including another test function that returns a concrete type such as int, as functions with a return type of auto are template functions.

@Burgos
Copy link
Member Author

Burgos commented Jun 14, 2017

Good point, updated with more test cases.

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.
body {}

auto bar()
out { assert (__result > 5); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure using that private identifier is something we want to advocate / test :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's an internal compiler test, I guess, so I was going with the thoughts that whoever removes __result, should do it contently and remove this test. Reason I've added it here in the first place is that this patch touches the code responsible for the generation of this identifier.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as the test suite goes, it is not intended to be an example of best practices. It's sole purpose is to test the compiler - so whatever works is fair game. (In fact, it's often terrible style.)

@Burgos
Copy link
Member Author

Burgos commented Jun 14, 2017

Damn Jenkins, why can't he leave me alone?

@dnadlinger
Copy link
Member

@Burgos: The Jenkins error is not due to your PR; master was accidentally broken a few days back.

@WalterBright WalterBright merged commit 620acd5 into dlang:master Jun 15, 2017
@Burgos Burgos deleted the out_param branch June 16, 2017 19:26
tramker pushed a commit to tramker/dmd that referenced this pull request Jun 26, 2017
[REG2.064] Fix issue 17502: Allow no parameters in out contract for auto methods

cherry-picked-by: Martin Krejcirik <mk@krej.cz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants