Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message "expected indented block" on misleading line #81046

Closed
miv391 opened this issue Aug 27, 2023 · 2 comments · Fixed by #85488
Closed

Error message "expected indented block" on misleading line #81046

miv391 opened this issue Aug 27, 2023 · 2 comments · Fixed by #85488

Comments

@miv391
Copy link
Contributor

miv391 commented Aug 27, 2023

Godot version

v4.1.1.stable.official [bd6af8e]

System information

Godot v4.1.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 6GB (NVIDIA; 31.0.15.3640) - Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 Threads)

Issue description

When a function body is missing, you get the following error message:

kuva

From the user's perspective the line displayed as an error line is totally wrong. I know that that is the line where the error is detected, but for the user it is a wrong line. At Godot subreddit it is quite often that users are stuck with these errors.

Another example where line 39 would be the most logical error location for the user. This is a little bit easier for the user as the error message tells that "for" block is missing something.

kuva

In my opinion the best fix would be to move the error location to the line that the error message refers to, in these examples function declaration line and for line. A small improvement would be to display the function name in the first example: Error at (41, 1): Expected inteded block after function declaration 'foo()'

Steps to reproduce

func foo():

func bar():
	pass
func foo():
	for i in range(2):

func bar():
	pass

Minimal reproduction project

N/A

@AThousandShips
Copy link
Member

This is probably because empty lines are valid indentation, so the first like that actually violates the indentation is the line indicated, though confusing it isn't wrong as such

It could be improved by backtracking over these empty lines though

@dalexeev
Copy link
Member

We could mark as error the node after which an indent is expected, in this case func or for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants