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]: Incorrect array initialisation with simultaneously changing global variables #40797

Closed
Nadeeshan96 opened this issue Jun 21, 2023 · 2 comments · Fixed by #40811
Closed
Assignees
Labels
Priority/High Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Milestone

Comments

@Nadeeshan96
Copy link
Contributor

Description

$title

Steps to Reproduce

import ballerina/io;

int a = 0;

public function main() {
    foo();
}

function foo() {
    int[] arr = [1, a, 3, bar(), a];
    io:println(arr);
}

function bar() returns int {
    a = a + 1;
    return a;
}

gives

[1,1,3,1,1]

But should give

[1,0,3,1,1]

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@Nadeeshan96 Nadeeshan96 added Type/Bug Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime and removed Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Jun 21, 2023
@Nadeeshan96
Copy link
Contributor Author

Nadeeshan96 commented Jun 21, 2023

lhsTempVarOptimizer of BIROptimizer removes the temp variables created for global variables.

@github-actions
Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@Nadeeshan96 Nadeeshan96 added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Aug 11, 2023
@Nadeeshan96 Nadeeshan96 added this to the 2201.8.0 milestone Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority/High Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
Archived in project
1 participant