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

variables created inside code blocks do not appear in debug window #38206

Closed
chucklepie opened this issue Apr 25, 2020 · 7 comments
Closed

variables created inside code blocks do not appear in debug window #38206

chucklepie opened this issue Apr 25, 2020 · 7 comments

Comments

@chucklepie
Copy link

chucklepie commented Apr 25, 2020

Godot version:
3.2.1

OS/device including version:
Linux Mint

In the screenshots below the breakpoint is at line 46, the line after 'newpos' is initialised.

If 'var newpos' is declared inside the if block (the second image), the debugger is not picking up the variable to put inside the debugger, and nor does hovering show any tooltip unless newpos is declared outside the if statement.

i.e. it appears the godot debugger is only tracking variables created at the current top level scope of a function.

image

image

@MWFIAE
Copy link

MWFIAE commented Apr 25, 2020

I could reproduce this behaviour at first.
But after a few tries it seems like godot cought up to the variable...

This was the code I used to reproduce it.
image

After replacing the print with breakpoint it did work as expected. Reverting it back to print didn't change anything, it continued to work as expected. Restarted godot in between because I thought maybe it's some kind of caching problem. But it continued to work even after a restart.

@chucklepie
Copy link
Author

Not for me, does it all of the time. Regardless, once is once too many :)

@chucklepie
Copy link
Author

I could reproduce this behaviour at first.
But after a few tries it seems like godot cought up to the variable...

I dunno if this makes a difference, but this function call was within the physics process function, not the ready function.

@BigRed-118
Copy link
Contributor

Can confirm, seeing this every time when setting a breakpoint in an if statement block in the physics process function, that is down from where the variable is declared or initialized. If I set a breakpoint on the initialization it's fine, but any line after that in the if statement block it doesn't show up in the debugger. Works if stepping line by line.

image
No testB
image

@BigRed-118
Copy link
Contributor

Also, I'm only seeing this behavior when the breakpoint is set on the last line of the if statement block (or stepping to the last line with the debugger). It looks like this is associated with the line that is chosen for the local variables to loose scope on. It's assigning it to be the last line of the block instead of the line after.

@chucklepie
Copy link
Author

I can confirm this too, well spotted.

So it's somebody got an index-1 problem ;)

I guess the fix for now is to add a pass or non-statement to the end of a block....

@akien-mga
Copy link
Member

Duplicate of #53442

@akien-mga akien-mga marked this as a duplicate of #53442 Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants