codegen, toplevel: check in function generation code