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

Fix expression inlining when working with macros #853

Merged
merged 10 commits into from
Nov 10, 2023

Conversation

TristonianJones
Copy link
Collaborator

@TristonianJones TristonianJones commented Oct 30, 2023

Fix expression inlining when working with macros

Inlining was only correctly accounting for situations when the expression to be
inlined did not contain any macros. Once macros were introduced, the identifier
references as well as the macro 'pointer' concept were not correctly being
propagated during inlining.

To preserve the 'pointer' concept, macro expression sub-graphs need to be
deleted when updating macro references. In the prior version of this code,
the sub-graphs were being preserved in the macro call metadata which resulted
in issues with round-tripping the expressions to a string, even though the logic
within the core AST was correct.

There are a few places in the code where expression IDs are being massaged in
order to account for lining up the id space between expressions and then for
propagating id changes down through macros. If there are ways to improve /
consolidate this logic in the future, then this is likely an area worth investing in.

@TristonianJones TristonianJones marked this pull request as draft October 30, 2023 20:26
@TristonianJones TristonianJones marked this pull request as ready for review November 6, 2023 23:28
cel/optimizer.go Outdated Show resolved Hide resolved
cel/optimizer.go Outdated Show resolved Hide resolved
cel/optimizer.go Outdated Show resolved Hide resolved
cel/optimizer.go Outdated Show resolved Hide resolved
cel/optimizer.go Outdated Show resolved Hide resolved
@TristonianJones
Copy link
Collaborator Author

PTAL @l46kok

Copy link
Collaborator

@jnthntatum jnthntatum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TristonianJones TristonianJones merged commit 1460938 into google:master Nov 10, 2023
2 checks passed
@TristonianJones TristonianJones deleted the inline-nested-macros branch November 10, 2023 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants