Fix creating a cycle by capturing an ancestor