• Peter Wortmann's avatar
    Annotation linting · 07d604fa
    Peter Wortmann authored
    This adds a way by which we can make sure that the Core passes treat
    annotations right: We run them twice and compare the results.
    
    The main problem here is that Core equivalence is awkward: We do not
    want the comparison to care about the order of, say, top-level or
    recursive bindings. This is important even if GHC generally generates
    the bindings in the right order - after all, if something goes wrong
    we don't want linting to dump out the whole program as the offense.
    
    So instead we do some heuristic matching - first greedily match
    everything that's easy, then match the rest by label order. This
    should work as long as GHC generates the labels in roughly the same
    order for both pass runs.  In practice it seems to work alright.
    
    We also check that IdInfos match, as this might cause hard-to-spot
    bugs down the line (I had at least one bug because unfolding guidance
    didn't match!). We especially check unfoldings up until the point
    where it might get us into an infinite loop.
    
    (From Phabricator D169)
    07d604fa
CoreUtils.hs 82.2 KB