Move "Expected indented block" error message's line number back to where the error is #85488
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 #81046
In master "Expected indented block ..." error messages are assigned to code lines likes this:
The error message at line 7 tells that "Expected indented block after class declaration". The class declaration mentioned in error messages in not at line 7, it is at line 4. Other errors in screenshot are similar. The most confusing (I have seen this at Reddit discussions several times) is the error at line 16 which mentions function declaration. But the problem is not the function declaration at line 16, the problematic function declaration is at line 11.
In master, the error message line is obviously the line where the missing indented block is noticed.
This PR fixes this problem and now the same errors look like this:
Now all "Expected indented block ..." error messages are pointing to lines which are actually expecting something.
Other kind of errors seem to be unaffected by this change:
But I haven't tested with every different error message and I don't have deep understanding about GDScript parser, so something may have broken. If there exists somewhere a test project which contains all possible GDScript error, I would be interested about that.
It might also be worth considering about changing these "Expected indented block ..." error messages a bit.
"Expected indented block after class declaration"
-->
"Expected indented block after this class declaration"
Adding "this" would emphasize the fact that it is exactly this function that needs indented block after it. But I may be overcautious here.