If a function/method is supposed to return a value, but could end up not flowing into a return statement, the compiler would compile without error:
/** * Test function. */ public int test(bool z) { if (z) return 3; } /** * Execute code. */ { test(false); }
cm> load("c:/CetDev/PureBase/personal/profile/yewch/t.cm"); true
Ideally, we would want the compiler to catch this in order to prevent errors. However this was a tradeoff made to reduce compilation times.
It is also more convenient during development/debugging not to be forced to make the code perfect when cutting code in and out.
CAB (Compile All Below)
You can catch these missing returns of packages by simply using the check()
function in cm/runtime/util/cab.cm.
/** * Test function. */ public int test(bool z) { if (z) return 3; } /** * Execute code. */ { check(#:package.str); }
cm> run("c:/CetDev/PureBase/personal/profile/yewch/t.cm"); cab load .. cab compile .. compile: profile.yewch c:\CetDev\PureBase\personal\profile\yewch\t.cm(43, 16): not all control paths return a value 376 ms 457 us, total=376 ms 459 us, lines=2 963 059 cab total=377 ms 58 us, parsed lines=0, load=452 us, compile=376 ms 534 us, 0 lines/min
You can also pass on multiple urls as a string into check()
:
check("cm, cm.abstract.draw, -cm.*.publish");
Within the same file, there is a reference in how to append your packages in a more advanced and precise manner:
/**
* Append targets.
* 'pkgs' is a ','-separated list of packages.
* heading and trailing spaces are stripped.
* any package preceded by '-' will be skipped.
*
* single wildcard
* cm.* -> equivalent to cm
* cm.*.test
* *.test
*
* example: "cm, -cm.*.test" (include all below cm, skip any .test-packages)
* example: "cm, -cm.test" (include cm, skip cm.test)
*
* If a package is mentioned twice in an add or skip, the last occurance will rule.
*/
Comments
0 comments
Please sign in to leave a comment.