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

Closure should capture the narrowed type when closure is created with in a narrowed environment #30567

Open
rdhananjaya opened this issue May 14, 2021 · 1 comment
Labels
Area/TypeChecker Type Checker related issues #Compiler Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@rdhananjaya
Copy link
Member

Description:

import ballerina/io;
public function main() {
    string? x = "hello";

    if (x is string) {
        var f = function() {
                    x = (); // static type of `x` should be `string` but it's `string?` now.
                };
        f();
        string kk = "--" + x + "--"; // x is no longer a string
        io:println(kk);
    }
}

Steps to reproduce:

Affected Versions:

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

@rdhananjaya rdhananjaya added Type/Bug Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/TypeChecker Type Checker related issues #Compiler labels May 14, 2021
@MaryamZi
Copy link
Member

MaryamZi commented Mar 1, 2022

Related spec issue - ballerina-platform/ballerina-spec#1043.

@gimantha gimantha added this to Issues in Essential Fixes for SwanLake Updates via automation May 8, 2022
@gimantha gimantha moved this from Issues to To Finalize theDesign in Essential Fixes for SwanLake Updates May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/TypeChecker Type Checker related issues #Compiler Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
Development

No branches or pull requests

2 participants