fix: Properly resolve prelude paths inside modules inside blocks #18422
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.
I.e. the following situation:
Those were previously unresolved, because, in order to support
self
andsuper
properly, since #15148 we do not ascend block paths when there is a module in between, but only crate def maps register preludes, not block def maps, and we can't change this because block def map prelude can always be overridden by another block. E.g.Here
WithTheSameNameAsPreludeItem
refer to the item from the top block, but if we would register prelude items in each block the child block would overwrite it incorrectly.Fixes #18411.
I don't like the approach I took with the code, but I thought many times and couldn't find something better. I extracted a lot into functions. Still, name resolution is a meh (because it's a meh in Rust, not because of our implementation).