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]: cloneWithType returns error for readonly records #41378

Closed
HindujaB opened this issue Sep 13, 2023 · 1 comment · Fixed by #40579
Closed

[Bug]: cloneWithType returns error for readonly records #41378

HindujaB opened this issue Sep 13, 2023 · 1 comment · Fixed by #40579
Assignees
Labels
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

Comments

@HindujaB
Copy link
Contributor

Description

$subject

Steps to Reproduce

import ballerina/io;

type Foo record {|
    int[] x = getX();
    int[] & readonly y = getY();
|};

isolated function getX() returns int[] {
    return [1];
}

isolated function getY() returns int[] & readonly {
    return [2];
}

public function main() {
    map<anydata> m = {y: <readonly> [3]};
    Foo & readonly n = checkpanic m.cloneWithType();
    io:println(n);
}

The above code returns an error as follows

error: {ballerina/lang.value}ConversionError {"message":"invalid value for record field 'x': expected value of type '(int[] & readonly)', found 'int[]'"}
        at ballerina.lang.value.0:cloneWithType(value.bal:114)
           hinduja.record_std_lib.0:main(temp.bal:25)

Expected output is

{"x":[1],"y":[3]}

The parallel to cloneWithType should behave similarly to creating the value with a constructor at compile-time.

Affected Version(s)

2201.7.2

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

@ballerina-bot ballerina-bot added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Sep 13, 2023
@HindujaB HindujaB self-assigned this Sep 14, 2023
@HindujaB HindujaB moved this to In Progress in Ballerina Team Main Board Sep 14, 2023
@HindujaB HindujaB moved this from In Progress to PR Sent in Ballerina Team Main Board Sep 20, 2023
@github-project-automation github-project-automation bot moved this from PR Sent to Done in Ballerina Team Main Board Dec 6, 2023
Copy link

github-actions bot commented Dec 6, 2023

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.

@chiranSachintha chiranSachintha added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Development

Successfully merging a pull request may close this issue.

3 participants