Open MaryamZi opened 3 months ago
Even with capture binding patterns, if we explicitly call a function like message()
on the error value in a match statement, the backend crashes. This happens on U8 also.
function f1(string str) returns int {
do {
check f2(str);
check f2(str);
} on fail error e {
match e.message() {
"Error 1" => {
return 1;
}
}
}
return 2;
}
function f2(string str) returns error? => ();
[2024-04-08 15:06:42,108] SEVERE {b7a.log.crash} - Cannot read field "kind" because "moveIns.rhsOp.variableDcl" is null
java.lang.NullPointerException: Cannot read field "kind" because "moveIns.rhsOp.variableDcl" is null
at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$RHSTempVarOptimizer.visit(BIROptimizer.java:157)
at org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRBasicBlock.accept(BIRNode.java:485)
at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$RHSTempVarOptimizer.lambda$visit$3(BIROptimizer.java:119)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$RHSTempVarOptimizer.visit(BIROptimizer.java:119)
at org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRFunction.accept(BIRNode.java:432)
at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$RHSTempVarOptimizer.lambda$visit$1(BIROptimizer.java:105)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$RHSTempVarOptimizer.visit(BIROptimizer.java:105)
at org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRPackage.accept(BIRNode.java:89)
at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer.optimizePackage(BIROptimizer.java:82)
at org.wso2.ballerinalang.compiler.bir.BIRGen.genBIR(BIRGen.java:291)
at io.ballerina.projects.internal.CompilerPhaseRunner.birGen(CompilerPhaseRunner.java:220)
at io.ballerina.projects.internal.CompilerPhaseRunner.performBirGenPhases(CompilerPhaseRunner.java:157)
at io.ballerina.projects.ModuleContext.generateCodeInternal(ModuleContext.java:454)
at io.ballerina.projects.ModuleCompilationState$4.generatePlatformSpecificCode(ModuleCompilationState.java:132)
at io.ballerina.projects.ModuleContext.generatePlatformSpecificCode(ModuleContext.java:387)
at io.ballerina.projects.JBallerinaBackend.performCodeGen(JBallerinaBackend.java:174)
at io.ballerina.projects.JBallerinaBackend.<init>(JBallerinaBackend.java:143)
at io.ballerina.projects.JBallerinaBackend.lambda$from$0(JBallerinaBackend.java:121)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
at io.ballerina.projects.PackageCompilation.getCompilerBackend(PackageCompilation.java:176)
at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:120)
at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:201)
at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
at io.ballerina.cli.cmd.RunCommand.execute(RunCommand.java:223)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at io.ballerina.cli.launcher.Main.main(Main.java:58)
The error BP has been temporarily disallowed on the U9 branch via https://github.com/ballerina-platform/ballerina-lang/pull/42503.
Need to also address https://github.com/ballerina-platform/ballerina-lang/blob/2201.9.x/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal#L591 when reverting the changes in that PR.
We have tried a few approaches:
Generate a separate function for statements within the on-fail clause. This method allows to desugar only once for the on-fail clause, but creating this function is complex, due to that we move away from this approach.
Clone the type binding and use it within the on-fail clause. While this seemed promising, we encountered some issues with this approach. The proposed solution is mentioned in the following doc.https://docs.google.com/document/d/1Dy7WLP7Ne8lqUKzIF89TYskf_8KmaBLLfb4XZypP7mw/edit?usp=sharing
With this task, we identified that the Do on-fail
within the Query Action isn't desugared correctly. This needs to be addressed first to resolve the issue as well. https://github.com/ballerina-platform/ballerina-lang/issues/42632
Description
$title.
Steps to Reproduce
Affected Version(s)
Current master (U9-snapshot)
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