[Issue 18614] New: dmd source uses bool return inconsistently (true should mean success)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 15 00:40:20 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18614
Issue ID: 18614
Summary: dmd source uses bool return inconsistently (true
should mean success)
Product: D
Version: D2
Hardware: x86
OS: All
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timothee.cour2 at gmail.com
usual convention is that a bool return function should return true on sucess
(makes it easy with `assert(run_fun(args))`
it's what's also commonly used, eg: core.runtime.Runtime.{intialize,terminate}
etc and also on parts of dmd (eg: override bool overloadInsert(Dsymbol s):
Return true if successful)
however we have these oddities in dmd:
```
// src/dmd/root/response.d:207:22
* Returns:
* 0 success
* !=0 failure (argc, argv unchanged)
*/
bool response_expand(Strings* args)
```
(also suspicious (prob historical reasons) because should be false and true,
not 0 and !=0)
and also these:
`Returns true if error`
(9 occurrences in dmd source code)
we should replace each such example with the correct convention, it's confusing
when reading corresponding code (especially caller code). Not a problem to
change these since the code is not used outside of this repo
--
More information about the Digitalmars-d-bugs
mailing list