-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix the invalid error for readonly record types #45
base: main
Are you sure you want to change the base?
Fix the invalid error for readonly record types #45
Conversation
native/src/main/java/io/ballerina/lib/data/jsondata/json/JsonParser.java
Show resolved
Hide resolved
ReadOnlyUser r = check parseString(user); | ||
test:assertEquals(r, {id: 4012}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add more tests with
- members of selectively-immutable types that become immutable because the type it is in is immutable - e.g., like the
id
field, but with a selectively-immutable type - field of a readonly intersection type in a mutable type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests for these scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please point to the relevant tests for each of these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testSimpleJsonToRecord6 , testSimpleJsonStringToRecord6
test functions
testSimpleJsonToRecord3, testSimpleJsonStringToRecord3
test functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- field of a readonly intersection type in a mutable type
Still can't find tests like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type ReadOnlyUsersRecord3 readonly & record {|
ReadonlyUserId[] ids;
ReadonlyUserName[] names;
|};
@test:Config
isolated function testSimpleJsonToRecord6() returns Error? {
json user = {ids: [4012, 4013], names: [{firstname: "John", lastname: "Doe"},
{firstname: "Jane", lastname: "Doe"}], age: 27};
ReadOnlyUsersRecord3 r = check parseAsType(user);
test:assertEquals(r, {ids: [4012, 4013], names: [{firstname: "John", lastname: "Doe"},
{firstname: "Jane", lastname: "Doe"}]});
}
In here ReadonlyUserName is a readobly type of a record type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was something like
type T1 record {
T2[] & readonly v;
};
Purpose
Fixes: ballerina-platform/ballerina-library#7253
Fixes: ballerina-platform/ballerina-library#7254
Examples
Checklist