Fix splicing of declarations in generated function