-
Notifications
You must be signed in to change notification settings - Fork 736
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
[Task]: Revamp cloneWithType
and fromJsonWithType
#39217
Comments
Tried to do a performance improvement in the First ran the langlib value tests in a large loop and measured the time and memory using Jprofiler.
Then converted a large json to a record in a large loop and measured the time and memory using Jprofiler.
Due to the above results, decided not to do the above change. |
Improve error message given in the failure of type conversion when the target type is a unionpublic function main() {
foo();
}
type NumberArray int[]|float[];
type StringArray string[]|string:Char[];
type NumberOrStringArray NumberArray|StringArray;
type RecordWithArrayAsAField record {|
NumberOrStringArray arr;
|};
type RecordWithNumberArrayAsAField record {|
NumberArray arr;
|};
function foo() {
json j = {"arr": [1,1.2,"a","aa"]};
RecordWithArrayAsAField|RecordWithNumberArrayAsAField jCloned = checkpanic j.cloneWithType();
} For example for the above code the error message is given as follows with all the errors together, which seems infeasible.
This can be improved for something like below.
|
Another bug: type JsonUnion xml|json;
type AnyDataUnion int|anydata;
public function main() {
xml a = xml `<a>1</a>`;
// JsonUnion & readonly j = checkpanic a.cloneWithType();
AnyDataUnion & readonly jj = checkpanic a.cloneWithType();
} gives
|
#39217 (comment) and #39217 (comment) is fixed with #39212. |
Closing the issue because the task is done. |
Description
$title
Describe your task(s)
fromJsonWithType
andcloneWithType
into a common implementation #39162table
,regexp:RegExp
types incloneWithType
is erroneous #38716xml
type usingcloneWithType
#38715cloneWithType
#39168CloneWithType
gives unexpected error when converting table to any data #39383fromJsonWithType
andcloneWithType
#38717string
values toxml
subtypes #39610cloneWithType
is not working with TypeReferenceType #39907Related area
-> Runtime
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: