Fix const issues in function.cpp

Signed-off-by: Pekka Enberg <penberg@iki.fi>