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

After modify global variable (collection-type), foreach should get newest value #17

Open
LeeKaiXuan opened this issue May 8, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@LeeKaiXuan
Copy link
Collaborator

Description

An action (e.g., appendList in the example) that modifies the global variable (e.g., foo_list in the example); and a foreach that iterates the variable. If both were located in the same activity block, the foreach didn't get the newer foo_list which was modified by appendList.

Scenario Code

component pss_top {
    action root_a {
        list<int> foo_list = {1, 2};

        activity {
            do printStr with { str == "root_a"; };
            foreach (i : foo_list[j]) {
                do printVal with { val in [i]; };
            }

            do appendList with { val in [3]; };

            do printStr with { str == "root_a"; };
            foreach (i : foo_list[j]) {
                do printVal with { val in [i]; };
            }
        }
    }

    action appendList {
        rand int val;
        exec post_solve {
            foo_list.push_back(val);
        }
        exec body ASM = """appendList: {{val}}""";
        activity {
            do printStr with { str == "appendList"; };
            foreach (i : foo_list[j]) {
                do printVal with { val in [i]; };
            }
        }
    }

    action printVal {
        rand int val;
        exec body ASM = """printVal: {{val}}""";
    }

    action printStr {
        rand string str;
        exec body ASM = """printStr: {{str}}""";
    }
}

Expected Output or Behaviour

printStr: root_a
printVal: 1
printVal: 2
appendList: 3
printStr: appendList
printVal: 1
printVal: 2
printVal: 3
printStr: root_a
printVal: 1
printVal: 2
printVal: 3

Error Message from PSSGen or JAVA

11a12
> printVal: 3
Test Result: FAIL

Additional Context (Optional)

Please feel free to add any other context about the problem here.

@LeeKaiXuan LeeKaiXuan added the bug Something isn't working label May 8, 2024
@LeeKaiXuan LeeKaiXuan self-assigned this May 8, 2024
LeeKaiXuan added a commit that referenced this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant