compiler: Exclude false scope members from encoded name duplication tracking #8681
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a very strange bug that likely stems from the way mutators work.
When mutating a model for visibility transforms, we create clones of the model's properties. These clones end up checked/finished, even if they are not actually attached to the model, and vice versa (the original properties may be checked/finished even if the clone ends up attached).
This runs stateful decorators, like
@encodedName
. Unfortunately, in these cases, it means that both the clone and the original property end up binding an encoded name within the same scope, which the validator later sees as a conflict.However, only one of these properties is actually a member of the scope at validation time. This PR uses that to exclude "false members". These are properties that exist in the state map (the decorator has been applied to them), but aren't actually bound to the parent they claim to be a member of. We can work around this mutator bug in the validator by checking if the target is actually within the set of member values (in this case, the properties actually present in the parent model, but this will also work for enum members and union variants).
Closes #8599