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

Fix for variables losing scope and disappearing from debugger #38608

Conversation

BigRed-118
Copy link
Contributor

@BigRed-118 BigRed-118 commented May 10, 2020

When breaking on or stepping to the last line of a p_block, the local
variables declared in that scope would be removed from the debugger.
This was because the current_line for removal set in gdscript_compiler.h,
pop_stack_identifiers ended up being the last line of the block, not
the line after. Now we set the current_line to be the end_line of the
p_block, only if the end_line is not -1

Reported: #38206

If anyone sees any issues with this let me know. From what I've seen, the end_line of a p_block was either a valid line or -1, but I could be mistaken. Thank you.

Bugsquad edit:

When breaking on or stepping to the last line of a p_block, the local
variables declared in that scope would be removed from the debugger.
This was because the current_line for removal set in gdscript_compiler.h,
pop_stack_identifiers ended up being the last line of the block, not
the line after. Now we set the current_line to be the end_line of the
p_block, only if the end_line is not -1
@BigRed-118
Copy link
Contributor Author

BigRed-118 commented May 10, 2020

The CF_xx block statements list doesn't end with a newline but with the last statement. Having the newline included might also be a solution for this, advancing to the next line at the end of the block, but I wasn't sure the impact it would have elsewhere.

@Chaosus Chaosus added this to the 4.0 milestone May 11, 2020
@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label May 12, 2020
@akien-mga akien-mga requested review from a team and removed request for bojidar-bg October 5, 2021 18:43
@Banderi
Copy link

Banderi commented Jan 8, 2023

This was fixed in 4.0 which is what the master branch targets, correct?
Would it be fine if somebody remade this PR for the 3.x branch?

@akien-mga
Copy link
Member

It would be good to do a new PR for 3.x yes.
Identifying what change fixed it in 4.0 could help inform whether the approach in this PR is correct, or if a better solution was found in 4.0 which would work on 3.x too.

@Banderi
Copy link

Banderi commented Jan 8, 2023

After a bit of narrowing down, this was the change that fixed it: #58201
Using the same approach, just changing this line from if (sd.line > p_line) { to if (sd.line >= p_line) { should do it - I'm gonna test if it works and open a PR for 3.x!

@akien-mga
Copy link
Member

akien-mga commented Jan 9, 2023

Superseded by #58201 (4.0) and #71093 (3.6).

@akien-mga akien-mga closed this Jan 9, 2023
@akien-mga akien-mga added archived and removed cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debugger loses variable scope in the last line of a block
4 participants