GDScript: Do phrase level recovery when parsing faulty dictionaries #102218
+177
−4
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.
Fixes #78602
Fixes #37061 (this is on the 3.x milestone, but I don't think we'll able to back port any fix, so we might as well close it)
Fixes partially #96157
Partial alternative to #79424
Descritpion from there:
In #79424 the parser would add such fully parsed parts to a new list "unfinished fragments" and the analyzer was adjusted to analyze this list as well. This PR takes a different approach and patches the tree in the parser in a way that is transparent to the analyzer. This is a better approach since it ensures that the analyzer encounters those fragments in the correct context.
The patched tree might be faulty on the analyzer level, but to the analyzer it looks like an syntactically correct file. Those analyzer errors resulting from faulty patching (e.g. patching a incompatible value into a typed dictionary) can be ignored, since analyzer errors are not shown as long as there are parser errors (which is always the case when we are patching the tree).
If we can reach any consensus on this approach I'll add recovery for the other cases from #79424 as well (ternaries and match statements). But I'd like to hear some thoughts on this first, since I don't think there is any precedence for this kind of recovery in the parser.