Generation and regioselective trapping of a 3,4-piperidyne for the synthesis of functionalized heterocycles.