[BZ-1136424] fix using declaration inside the same or pattern where the variable is declared