Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
December 04, 2019 [Issue 20428] Precondition bug for in/out | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20428 FeepingCreature <default_357-line@yahoo.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |default_357-line@yahoo.de --- Comment #1 from FeepingCreature <default_357-line@yahoo.de> --- Sorta a bug but not really. More a really confusing aspect of how in-conditions work. By substitutability, a subclass can always say that it chooses to accept more data as parameters than its parent class or interface demands. Contracts are an extension of this mechanism, so an in-condition on an interface is mostly useless - the subclass only *has to* accept all the values that the interface in-condition lets through; but it can always choose to accept more values. (This is fundamental to what inheritance formally means.) In D, a lack of in-condition is taken to mean "the function takes any value allowed by the type." As such, you can always override a method with an in-condition with one that doesn't have an in-condition, which is taken to dissolve the in-condition. Now, from a language design perspective it would probably be better if "no in-condition" meant "copy the in-condition of the parent interface" and you'd signal the desire to accept any value with something like "in (true)". However, that'd be a feature proposal, not a bug. -- |
December 04, 2019 [Issue 20428] Precondition bug for in/out | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20428 --- Comment #2 from FeepingCreature <default_357-line@yahoo.de> --- Just to make it clearer: interface I { void foo(int i) in (i < 10); } This means that for any implementation of I, foo() *has to* take all i < 10. But it can always *choose* to additionally take i >= 10. And by default, if you specify no in-condition in C : I {}, it does. -- |
July 12, 2021 [Issue 20428] Precondition bug for in/out | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20428 Dennis <dkorpel@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |contracts CC| |dkorpel@live.nl Hardware|x86_64 |All OS|Linux |All Severity|critical |enhancement --- Comment #3 from Dennis <dkorpel@live.nl> --- Not a bug, derived classes must tighten the outputs but can loosen the inputs: https://dlang.org/spec/function.html#in_out_inheritance Running checks on derived classes would break valid code. Changing this to an enhancement "copy parent's contracts by default" like FeepingCreature suggested, though that might need a DIP since it's a breaking change as well. -- |
December 02, 2022 [Issue 20428] Precondition bug for in/out | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20428 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=23535 -- |
December 17, 2022 [Issue 20428] Precondition bug for in/out | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20428 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P4 -- |
December 13 [Issue 20428] Precondition bug for in/out | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20428 --- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19645 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation