dmd
dmd copied to clipboard
fix Issue 21298 - Missing error when overriding interface method with…
…out in contract with class method with contract
Thanks for your pull request, @WalterBright!
Bugzilla references
| Auto-close | Bugzilla | Severity | Description |
|---|---|---|---|
| ✓ | 21298 | minor | Missing error when overriding interface method without in contract with class method with contract |
Testing this PR locally
If you don't have a local development environment setup, you can use Digger to test this PR:
dub run digger -- build "master + dmd#12013"
This has failures in phobos. Should this require a deprecation?
The errors are happening because the overridden function is abstract and so has no implementation. But before worrying about that, as I wrote in the bugzilla issue, I'm not sure the issue is even valid.
The issue is valid. Look at this example:
interface I
{
int foo(int i) out (r; r>0);
}
class C : I
{
override int foo(int i) in (i > 0) { return i; }
}
This results in: "Error: function onlineapp.C.foo cannot have an in contract when overridden function onlineapp.I.foo does not have an in contract"
If this works, then I don't see any reason why it would simply compile when the contract is missing in the interface function.
The way forward would be to issue a deprecation.