Description
Bounds expressions aren't allowed to contain modifying expressions. It is possible for bounds inference to create bounds expressions containing modifying expressions when inferring bounds expressions for member operator expressions.
We have code that attempts to disallow the creation of invalid bounds expressions for this case by making the bounds be unknown. This is wrong because it can cause the compiler to skip checking bounds declarations when the inferred target bounds for the LHS of an assignment contain a modifying expression. Consider:
struct S {
array_ptr<int> f : count(len);
int len;
};
struct S *p;
(p++)->f = ...
The inferred target bounds are bounds ((p++)->f, (p++)->f + (p++)->len). This would be changed to bounds(unknown), leading to no checking of that the assignment to f maintains the bounds declarations.
Instead of trying to hack the inference analysis, directly check that bounds expressions created by bounds inference are non-modifying expressions.