4 ms·
Having implicit returns has been a source of bugs and vulnerabilities in code [1][2][3]. Essentially, it results in accidental return of temporary values, espec
by ghusbands 5y ago
Having implicit returns has been a source of bugs and vulnerabilities in code [1][2][3]. Essentially, it results in accidental return of temporary values, especially in cases in which people don't want to return anything.
[1] https://github.com/CodeNarc/CodeNarc/issues/450 https://github.com/CodeNarc/CodeNarc/issues/450
[2] https://stackoverflow.com/questions/24070544/suppressing-implicit-returns-in-swift https://stackoverflow.com/questions/24070544/suppressing-imp...
[3] https://nug.xojo.narkive.com/GvvcWglM/bug-command-keys-are-absorbed-by-menu-handlers-on-mac-but-not-on-windows https://nug.xojo.narkive.com/GvvcWglM/bug-command-keys-are-a...
- slver 5y agoIf you don't want to return anything you'd declare your function return type as void, so that's probably more in dynamically typed systems.
- magicalhippo 5y agoWe've had cases at work where the issue is that a void function (procedure) is converted to a "proper" function, and some return paths are missed. For our compiler, for certain types it fails to warn that the return variable is unassigned, hence bugs occur. This is a statically typed language, it's just an unfortunate interaction between compiler magic and the code that checks for unassigned return variables.