ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.68k stars 753 forks source link

[Bug]: Bad. Sad error when pushing an object array to an array. #39764

Open Ishad-M-I-M opened 1 year ago

Ishad-M-I-M commented 1 year ago

Description

Compiler run time crashed with the following error

Compiling source
        ballerina/graphql:1.6.2
ballerina: Oh no, something really went wrong. Bad. Sad.

We appreciate it if you can report the code that broke Ballerina in
https://github.com/ballerina-platform/ballerina-lang/issues with the
log you get below and your sample code.

We thank you for helping make us better.

[2023-03-01 13:16:38,793] SEVERE {b7a.log.crash} - null
java.lang.NullPointerException
        at org.wso2.ballerinalang.compiler.desugar.Desugar.getInvocation(Desugar.java:6459)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.createStmtExpr(Desugar.java:6434)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:6379)
        at org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation.accept(BLangInvocation.java:128)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewriteExpr(Desugar.java:8926)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:3526)
        at org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt.accept(BLangExpressionStmt.java:51)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8939)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewriteStmt(Desugar.java:8945)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:1607)
        at org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt.accept(BLangBlockStmt.java:65)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8939)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:3533)
        at org.wso2.ballerinalang.compiler.tree.statements.BLangIf.accept(BLangIf.java:60)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8939)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewriteStmt(Desugar.java:8945)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:1607)
        at org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt.accept(BLangBlockStmt.java:65)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8939)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:5360)
        at org.wso2.ballerinalang.compiler.tree.statements.BLangWhile.accept(BLangWhile.java:81)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8939)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewriteStmt(Desugar.java:8945)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:1380)
        at org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody.accept(BLangBlockFunctionBody.java:60)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:1426)
        at org.wso2.ballerinalang.compiler.tree.BLangFunction.accept(BLangFunction.java:76)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:1176)
        at org.wso2.ballerinalang.compiler.tree.BLangClassDefinition.accept(BLangClassDefinition.java:124)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8952)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:811)
        at org.wso2.ballerinalang.compiler.tree.BLangPackage.accept(BLangPackage.java:167)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:8901)
        at org.wso2.ballerinalang.compiler.desugar.Desugar.perform(Desugar.java:473)
        at io.ballerina.projects.internal.CompilerPhaseRunner.desugar(CompilerPhaseRunner.java:216)
        at io.ballerina.projects.internal.CompilerPhaseRunner.performBirGenPhases(CompilerPhaseRunner.java:152)
        at io.ballerina.projects.ModuleContext.generateCodeInternal(ModuleContext.java:451)
        at io.ballerina.projects.ModuleCompilationState$4.generatePlatformSpecificCode(ModuleCompilationState.java:132)
        at io.ballerina.projects.ModuleContext.generatePlatformSpecificCode(ModuleContext.java:385)
        at io.ballerina.projects.JBallerinaBackend.performCodeGen(JBallerinaBackend.java:170)
        at io.ballerina.projects.JBallerinaBackend.<init>(JBallerinaBackend.java:139)
        at io.ballerina.projects.JBallerinaBackend.lambda$from$0(JBallerinaBackend.java:117)
        at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
        at io.ballerina.projects.PackageCompilation.getCompilerBackend(PackageCompilation.java:170)
        at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:116)
        at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:165)
        at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
        at io.ballerina.cli.cmd.PackCommand.execute(PackCommand.java:250)
        at java.base/java.util.Optional.ifPresent(Optional.java:183)
        at io.ballerina.cli.launcher.Main.main(Main.java:51)

ERROR [graphql:(1:1,1:1)] Compilation failed due to an unhandled exception
error: compilation contains errors

Steps to Reproduce

- Run `.\gradlew clean build` 

The compilation runtime crashes only if the commented line is there and compilation get successful when it is refactored as below.
```ballerina
Field[] fieldsToPush = self.getFieldObjects(fragmentSelectionNode, fieldType);
result.push(...fieldsToPush);

Affected Version(s)

2201.4.0

OS, DB, other environment details and versions

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

hasithaa commented 1 year ago

@ushirask. Let's test this on top of Update 7. Since it includes, SymbolEnter changes.