The Ordering and DAG detection code is challenging because we need Ordering to do SetScope, but Ordering itself needs to know about scopes. This improved variant should hopefully catch all the scenarios of identically named variables causing invalid loops. Co-authored-by: Samuel Gélineau <gelisam@gmail.com>