Bug 18614 – dmd source uses bool return inconsistently (true should mean success)

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2018-03-15T00:40:20Z
Last change time
2024-12-13T18:57:52Z
Assigned to
No Owner
Creator
Timothee Cour
Moved to GitHub: dmd#19410 →

Comments

Comment #0 by timothee.cour2 — 2018-03-15T00:40:20Z
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
Comment #1 by robert.schadek — 2024-12-13T18:57:52Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19410 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB