ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Incorrect results for xml attributes, when the expected type is a open record #6925

Open SasinduDilshara opened 2 months ago

SasinduDilshara commented 2 months ago

code

import ballerina/data.xmldata;
import ballerina/test;

xml x2 = xml `<A a1="2024" a2="3.14">Sample Text</A>`;

type A23 record {string \#content; int|decimal a1;};

public function main() {
    A23|error a23 = xmldata:parseAsType(x2);
    test:assertEquals(a23, {"#content":"Sample Text","a1":2024, "a2": <decimal>3.14}); // assertion failed
}

The current output of the above code is {"#content":"Sample Text","a1":2024} But the correct output should be {"#content":"Sample Text","a1":2024,"a2":3.14}