Protect against users calling Derive with a wrong ValueDecl.
Use NDEBUG only of to do it only in debug mode.
Dereference just once the argIndex. Early return when we know we cannot continue.
We need to close the return earlier because the code should be invariant on the if stmt.
Only refer to dependent variables through indices (i.e. IntegerLiterals).

Do not rely on ParamVarDecls of unknown (to the derived fn) origin.
Merge pull request #1 from mvassilev/master

Protect against users calling Derive with a wrong ValueDecl.