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]: Un-init variable error for variables initialised through object constructor init method #41013

Open
pcnfernando opened this issue Jul 14, 2023 · 0 comments
Labels
Area/CodeAnalysis Data flow , Code and Closure analysis related issues #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@pcnfernando
Copy link
Member

Description

Object constructors init method should be considered in the flow of execution and the compilation error can be avoided.

import ballerina/io;

public function main() returns error? {
    int i;
    var _ = object {
        function init() {
            i = 2;
        }
    };
    io:println(i); //unit var error
}

Steps to Reproduce

No response

Affected Version(s)

2201.7.0

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@pcnfernando pcnfernando added Type/Bug Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/CodeAnalysis Data flow , Code and Closure analysis related issues #Compiler labels Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/CodeAnalysis Data flow , Code and Closure analysis related issues #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
None yet
Development

No branches or pull requests

1 participant