Commit 73b43aa
Fix error in AnyOf (#14027)
# Objective
- Fixes a correctness error introduced in
#14013 ...
## Solution
I've been playing around a lot of with the access code and I realized
that I introduced a soundness error when trying to simplify the code.
When we have a `Or<(With<A>, With<B>)>` filter, we cannot call
```
let mut intermediate = FilteredAccess::default();
$name::update_component_access($name, &mut intermediate);
_new_access.append_or(&intermediate);
```
because that's just equivalent to adding the new components as `Or`
clauses.
For example if the existing `filter_sets` was `vec![With<C>]`, we would
then get `vec![With<C>, With<A>, With<B>]` which translates to `A or B
or C`.
Instead what we want is `(A and B) or (A and C)`, so we need to have
each new OR clause compose with the existing access like so:
```
let mut intermediate = _access.clone();
// if we previously had a With<C> in the filter_set, this will become `With<C> AND With<A>`
$name::update_component_access($name, &mut intermediate);
_new_access.append_or(&intermediate);
```
## Testing
- Added a unit test that is broken in main, but passes in this PR1 parent 20638f3 commit 73b43aa
2 files changed
+14
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1864 | 1864 | | |
1865 | 1865 | | |
1866 | 1866 | | |
1867 | | - | |
1868 | | - | |
1869 | | - | |
1870 | 1867 | | |
1871 | 1868 | | |
1872 | 1869 | | |
1873 | 1870 | | |
1874 | 1871 | | |
1875 | | - | |
1876 | | - | |
| 1872 | + | |
| 1873 | + | |
1877 | 1874 | | |
1878 | 1875 | | |
1879 | 1876 | | |
| |||
1884 | 1881 | | |
1885 | 1882 | | |
1886 | 1883 | | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
1887 | 1889 | | |
1888 | 1890 | | |
1889 | 1891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
566 | 573 | | |
567 | 574 | | |
568 | 575 | | |
| |||
0 commit comments