Extended semantic analysis for nonlocal declarations