cedar-policy / cedar

Implementation of the Cedar Policy Language
https://www.cedarpolicy.com
Apache License 2.0
889 stars 80 forks source link

Reorganize `to_expr_or_special` for `cst::Member` #1262

Closed john-h-kastner-aws closed 1 month ago

john-h-kastner-aws commented 1 month ago

Description of changes

This method has always struck me as unnecessarily complex. This PR tries to simplify it by observing that most of the cases can only occur on the first iteration of the loop. On the first iteration, we might have an access on a name (foo.bar), variable (principal.bar), string-literal ("foo".bar) or expression ((principal.foo).bar), but on all subsequent iterations we can only have the expression case. The string literal case was identical to the expression case, so these can share code.

Issue #, if available

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

I confirm that this PR (choose one, and delete the other options):

I confirm that cedar-spec (choose one, and delete the other options):

I confirm that docs.cedarpolicy.com (choose one, and delete the other options):