6242 – Disallow inoperant "in" contracts

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6242 - Disallow inoperant "in" contracts
Summary: Disallow inoperant "in" contracts
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: accepts-invalid, patch
Depends on:
Blocks:
Reported: 2011年07月02日 21:21 UTC by Andrei Alexandrescu
Modified: 2011年07月04日 19:16 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2011年07月02日 21:21:52 UTC
Consider:
class A { void fun(int) {} }
class B : A { void fun(int x) in { assert(x > 0); } body {} }
In this case B's in contract is never called. The compiler should disallow the code. To make the code work, an empty "in" contract on A.fun should suffice. The error message should mention that.
Comment 1 yebblies 2011年07月02日 22:06:52 UTC
https://github.com/D-Programming-Language/dmd/pull/196 
Comment 3 kennytm 2011年07月04日 11:21:03 UTC
Reopened as currently the code is still accepted. Perhaps pull 207 needs to be merged first.
https://github.com/D-Programming-Language/dmd/pull/207 


AltStyle によって変換されたページ (->オリジナル) /