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

Compiler gives incorrect error for variable usage in xml interpolated expressions

Open gimantha opened this issue 3 years ago • 1 comments

Consider the following code

import ballerina/io;

public function main() {
    int|decimal|float|string|boolean firstExpr = 34;
    xml<xml:Element> secondExpr = xml `<Book>"${firstExpr}"</Book>`;
}

This gives the following error incompatible types: expected '(int|float|decimal|string|boolean|xml)', found '(int|decimal|float|string|boolean)'

Infact, the firstExpr is allowed in xml as it is simpleType

gimantha avatar Oct 05 '21 14:10 gimantha