By checking if the variable is declared within a lambda abstraction that encompasses its occurrences.