Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topdown/copypropagation: keep refs into livevars #4936

Merged

Commits on Jul 26, 2022

  1. topdown/copypropagation: keep refs into livevars

    Before, a query of
    
        input.a == input.a
    
    would not survive copypropagation.
    
    With this change, it'll be recorded as removedEq, and subsequent processing
    steps ensure that it's kept in the body.
    
    Changing the sort order in sortBindings allows us to limit the unnecessary
    variable bindings: with the previous ordering, we'd get
    
        __local0__1 = input; __localcp0__ = input.a
    
    for the query `x := input; input.a == input.a`. Sorting the other way, we'll
    process `__localcp0__ = input.a` first, add it to the body, and when we check
    `__local0__1 = input`, we find that `input` is already contained in the body,
    and is thus not needed.
    
    Fixes open-policy-agent#4848.
    
    Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
    srenatus committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    2465f34 View commit details
    Browse the repository at this point in the history