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

[Bug Report] Buggy visualization for variables going out of scope #61

Open
jetline0 opened this issue Sep 28, 2024 · 1 comment
Open

Comments

@jetline0
Copy link

Describe the bug
The visualizer is inconsistent in how it visualizes variables going out of scope. In some instances, a variable going out of scope will be treated as such and will disappear once the visualizer steps out of the block the variable was defined in. In other cases, like in our example with a for loop, the variable persists after the block is exited.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the visualizer
  2. Paste the following code snippet:
int main(){
    int a = 0;
    for (int b = 0; b < 1; b++){
        int c = 15150;
        a++;
    }
    int b = 1;
    return 0;
}
  1. Compile the program
  2. Step through the program and notice how c will persist after the for loop

Expected behavior
We expect c to not be in scope after the for loop exits.

Here is a program that works as expected:

int main(){
    int a = 0;
    if (a == 0) {
        int x = 5;
    }
    int b = 1;
    return 0;
}

where x will not be in scope after the line int b = 1; is executed.

Screenshots
Failing program:
image

Sample working program:
image

@MarkChenYutian
Copy link
Owner

Thanks for reporting the bug 😄 (First external issue in this repo lol)

I will look into this later and post following updates here.

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

No branches or pull requests

2 participants