-
Notifications
You must be signed in to change notification settings - Fork 808
Open
Labels
Type/BugneedTriageThe issue has to be inspected and labeled manuallyThe issue has to be inspected and labeled manuallyuserCategory/Compilation
Description
Description
For the given code, when attempted to run, the compiler gives an error as following
Source
types.bal
import ballerina/data.xmldata;
type Holder record {|
string id;
string name;
|};
type RetDependentsItem record {|
string id;
string name;
string relationship;
|};
type Dependents json[];
type ServicesItem record {|
string cpt;
string coverage;
int units;
decimal unitPrice;
decimal copay;
|};
type Services ServicesItem[];
type ClaimsItem record {|
string claimId;
string date;
string memberId;
Services services;
|};
type Claims ClaimsItem[];
type PoliciesItem record {|
string policyId;
Holder holder;
Dependents dependents;
Claims claims;
|};
type Policies PoliciesItem[];
type InsData record {|
Policies policies;
|};
type Coverage record {
@xmldata:Attribute
string total;
@xmldata:Attribute
string 'type;
};
type CoverageRollup record {
Coverage[] Coverage;
};
type RetLine record {
string index;
};
type RetLines record {
RetLine[] Line;
};
type RetClaim record {
RetLines Lines;
@xmldata:Attribute
string date;
@xmldata:Attribute
string id;
@xmldata:Attribute
string index;
@xmldata:Attribute
string memberId;
@xmldata:Attribute
string total;
};
type RetClaims record {
RetClaim[] Claim;
};
type RetPolicy record {
CoverageRollup CoverageRollup;
RetClaims Claims;
@xmldata:Attribute
string claims;
@xmldata:Attribute
string dependents;
@xmldata:Attribute
string holder;
@xmldata:Attribute
string holderName;
@xmldata:Attribute
string id;
@xmldata:Attribute
string index;
@xmldata:Attribute
string total;
};
@xmldata:Name {
value: "Policies"
}
type RetPolicies record {
RetPolicy[] Policy;
@xmldata:Attribute
string grandTotal;
@xmldata:Attribute
string totalPolicies;
};
main.bal
import ballerina/http;
import ballerina/log;
service / on newlistner {
@http:ResourceConfig {
name: "sampleResource"
}
resource function post summary(@http:Payload InsData payload) returns xml {
do {
Claims claims = [];
_ = from var claimsItem in claims
select {
date: claimsItem.date,
memberId: "",
Lines: {
Line: from var _ in claimsItem.services
let var _ = claimsItem.services
select {index: "0"}
},
id: "",
index: "ll",
total: ""
};
return xml ``;
} on fail error err {
log:printError("Error converting to XML", err);
return xml ``;
}
}
}
listener http:Listener newlistner = new (port = 8000);
Compilation Error
[2026-02-20 15:26:55,695] SEVERE {b7a.log.crash} - Failed to find the closure symbol defined scope
java.lang.IllegalStateException: Failed to find the closure symbol defined scope
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.findClosureMapSymbol(ClosureDesugar.java:777)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.createAssignmentToClosureMap(ClosureDesugar.java:756)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:737)
at org.wso2.ballerinalang.compiler.tree.statements.BLangSimpleVariableDef.accept(BLangSimpleVariableDef.java:50)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewriteStmts(ClosureDesugar.java:2200)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:599)
at org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody.accept(BLangBlockFunctionBody.java:60)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:579)
at org.wso2.ballerinalang.compiler.tree.BLangFunction.accept(BLangFunction.java:79)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:1402)
at org.wso2.ballerinalang.compiler.tree.expressions.BLangLambdaFunction.accept(BLangLambdaFunction.java:64)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewriteExpr(ClosureDesugar.java:2192)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:1032)
at org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable.accept(BLangSimpleVariable.java:54)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:729)
at org.wso2.ballerinalang.compiler.tree.statements.BLangSimpleVariableDef.accept(BLangSimpleVariableDef.java:50)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:2047)
at org.wso2.ballerinalang.compiler.tree.expressions.BLangStatementExpression.accept(BLangStatementExpression.java:53)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewriteExpr(ClosureDesugar.java:2192)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:1032)
at org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable.accept(BLangSimpleVariable.java:54)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:729)
at org.wso2.ballerinalang.compiler.tree.statements.BLangSimpleVariableDef.accept(BLangSimpleVariableDef.java:50)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:2047)
at org.wso2.ballerinalang.compiler.tree.expressions.BLangStatementExpression.accept(BLangStatementExpression.java:53)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewriteExpr(ClosureDesugar.java:2192)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:1394)
at org.wso2.ballerinalang.compiler.tree.expressions.BLangTypeConversionExpr.accept(BLangTypeConversionExpr.java:83)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewriteExpr(ClosureDesugar.java:2192)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:1081)
at org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment.accept(BLangAssignment.java:81)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewriteStmts(ClosureDesugar.java:2200)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:701)
at org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt.accept(BLangBlockStmt.java:65)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewriteStmts(ClosureDesugar.java:2200)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:599)
at org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody.accept(BLangBlockFunctionBody.java:60)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:579)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:540)
at org.wso2.ballerinalang.compiler.tree.BLangResourceFunction.accept(BLangResourceFunction.java:40)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.rewrite(ClosureDesugar.java:2155)
at org.wso2.ballerinalang.compiler.desugar.ClosureDesugar.visit(ClosureDesugar.java:258)
at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:854)
at org.wso2.ballerinalang.compiler.tree.BLangPackage.accept(BLangPackage.java:171)
at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:9450)
at org.wso2.ballerinalang.compiler.desugar.Desugar.perform(Desugar.java:500)
at io.ballerina.projects.internal.CompilerPhaseRunner.desugar(CompilerPhaseRunner.java:201)
at io.ballerina.projects.internal.CompilerPhaseRunner.performBirGenPhases(CompilerPhaseRunner.java:137)
at io.ballerina.projects.ModuleContext.generateCodeInternal(ModuleContext.java:433)
at io.ballerina.projects.ModuleCompilationState$4.generatePlatformSpecificCode(ModuleCompilationState.java:132)
at io.ballerina.projects.ModuleContext.generatePlatformSpecificCode(ModuleContext.java:359)
at io.ballerina.projects.JBallerinaBackend.performCodeGen(JBallerinaBackend.java:177)
at io.ballerina.projects.JBallerinaBackend.<init>(JBallerinaBackend.java:143)
at io.ballerina.projects.JBallerinaBackend.lambda$from$0(JBallerinaBackend.java:127)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1228)
at io.ballerina.projects.PackageCompilation.getCompilerBackend(PackageCompilation.java:169)
at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:126)
at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:114)
at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:250)
at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
at io.ballerina.cli.cmd.RunCommand.executeTasks(RunCommand.java:367)
at io.ballerina.cli.cmd.RunCommand.execute(RunCommand.java:331)
at io.ballerina.cli.utils.RunCommandExecutor.run(RunCommandExecutor.java:55)
Steps to Reproduce
$Description
Affected Version(s)
No response
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type/BugneedTriageThe issue has to be inspected and labeled manuallyThe issue has to be inspected and labeled manuallyuserCategory/Compilation