All refactored functions have the exact same functionality but with better (updated) documentation and more readable code and concise code.
There is one exception, TCgetNthExprsExpr
, which I made non-nullable because I consider its nullability to be of no use & the tests run fine.
Old documented behaviour:
If n > chain length
, return NULL
. Otherwise, return EXPRS_EXPR
of the nth expression.
What it actually did:
If n == chain length
, return NULL
. If n > chain length
, abort. Otherwise, return EXPRS_EXPR
of the nth expression.
What it does now:
If n >= chain length
, abort. Otherwise, return EXPRS_EXPR
of the nth expression.
If we do have cases where what it actually did is what we want, then in my opinion we should have another function TCgetNthExprsExprOrNull
for that. That function can then return NULL instead of aborting.