ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[Bug]: Compound Assignment operator `+=` allows adding xml values to variables of xml built-in subtypes

Open poorna2152 opened this issue 1 year ago • 0 comments

Description

Consider the following scenarios,

public function main() {
    xml:Element x1 = xml `<foo/>`;
    x1 += xml `<bar/>`;

    xml:ProcessingInstruction x2 = xml `<?foo?>`;
    x2 += xml `<bar/>`;

    xml:Comment x3 = xml `<!--foo-->`;
    x3 += xml `<?bar?>`;
}

These should ideally return an error. However the following code gives the expected error.

public function main() {
    xml:Element x1 = xml `<foo/>`;
    x1 = x1 + xml `<bar/>`;

    xml:ProcessingInstruction x2 = xml `<?foo?>`;
    x2 = x2 + xml `<bar/>`;

    xml:Comment x3 = xml `<!--foo-->`;
    x3 = x3 + xml `<?bar?>`;
}

Steps to Reproduce

No response

Affected Version(s)

2201.8.6

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

poorna2152 avatar Mar 20 '24 00:03 poorna2152