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]: 'Extract to function' code action incorrectly pick the input parameter type and the output type #43729

Open
madushajg opened this issue Jan 2, 2025 · 0 comments
Labels
Area/CodeAction Language Server Code Actions Team/LanguageServer Language Server Implementation related issues. #Compiler Type/Bug

Comments

@madushajg
Copy link
Contributor

Description

Screen.Recording.2025-01-02.at.13.53.04.mov

Source:

type Person record {
    string id;
    string firstName;
    string lastName;
    int age;
    string country;
    string courseName;
};

type Course record {
    string id;
    string name;
    int credits;
};

type Student record {
    string id;
    string fullName;
    string age;
    record {
        string title;
        int credits;
    } course;
    int totalCredits;
    string visaType;
};

function tnf(Person person, Course course) returns Student => {
    course: extracted1(person)
};

function extracted1(Person person) returns record { string title;  int credits; } {
    return {};
}

as captured in the above Data Mapping scenario, the generated function has picked an incorrect input type. In this case the generated function should be

function extracted1(Person person) returns record { string title;  int credits; } {
    return {
        credits: 0,
        title: ""
    };
}

and the mapping should be,

function tnf(Person person, Course course) returns Student => {
    course: extracted1(person.courseName)
};

also reported in: wso2/ballerina-vscode#571

Steps to Reproduce

No response

Affected Version(s)

No response

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

@madushajg madushajg added Type/Bug Team/LanguageServer Language Server Implementation related issues. #Compiler Area/CodeAction Language Server Code Actions labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/CodeAction Language Server Code Actions Team/LanguageServer Language Server Implementation related issues. #Compiler Type/Bug
Projects
None yet
Development

No branches or pull requests

1 participant