The first argument of a functions gets overwitten (changed) when the second argument of that function is the return of anther invocation of that same function. Thus:
func(arg1, func(arg2, arg3)) becomes func(arg2, func(arg2, arg3))
The attached file compiles but it gives incorrect results.
iverilog function-tb.v ; ./a.out