Add return type checking for generators

Properly free the ast child as well.