Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Compiler crash with nested query expression containing another non nested field #43336

Open
poorna2152 opened this issue Aug 28, 2024 · 0 comments · May be fixed by #43355
Open

[Bug]: Compiler crash with nested query expression containing another non nested field #43336

poorna2152 opened this issue Aug 28, 2024 · 0 comments · May be fixed by #43355
Assignees
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@poorna2152
Copy link
Contributor

Description

Consider the following code,

type AccountDetail record {
    Assest[] assets;
    string accountType;
};

type UpdatedAccountDetail record {
    UpdatedAssest[] Assets;
    string AccountType;
};

type Assest record {
    string marketValue;
    string name;
};

type UpdatedAssest record {
    string MktValue;
    string Name;
};

isolated function constructAllocationSummary(AccountDetail[] accountDetails) {
    UpdatedAccountDetail[] _ = from AccountDetail detail in accountDetails
        select {
            Assets: from Assest asset in detail.assets
                select {
                    MktValue: asset.marketValue,
                    Name: asset.name
                },
            AccountType: detail.accountType
        };
}

This code gives a compiler crash with the following stacktrace.

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.

[2024-08-28 15:12:07,930] 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:169)
        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:131)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$RHSTempVarOptimizer.visit(BIROptimizer.java:131)
        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:117)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$RHSTempVarOptimizer.visit(BIROptimizer.java:117)
        at org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRPackage.accept(BIRNode.java:89)
        at org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer.optimizePackage(BIROptimizer.java:89)
        at org.wso2.ballerinalang.compiler.bir.BIRGen.genBIR(BIRGen.java:294)
        at io.ballerina.projects.internal.CompilerPhaseRunner.birGen(CompilerPhaseRunner.java:216)
        at io.ballerina.projects.internal.CompilerPhaseRunner.performBirGenPhases(CompilerPhaseRunner.java:153)
        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:173)
        at io.ballerina.projects.JBallerinaBackend.<init>(JBallerinaBackend.java:142)
        at io.ballerina.projects.JBallerinaBackend.lambda$from$0(JBallerinaBackend.java:126)
        at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
        at io.ballerina.projects.PackageCompilation.getCompilerBackend(PackageCompilation.java:179)
        at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:125)
        at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:113)
        at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:219)
        at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
        at io.ballerina.cli.cmd.RunCommand.execute(RunCommand.java:262)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
 
ERROR [xmlns_def:(1:1,1:1)] Compilation failed due to: Cannot read field "kind" because "moveIns.rhsOp.variableDcl" is null
error: compilation contains errors

Steps to Reproduce

No response

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

@poorna2152 poorna2152 added Type/Bug Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Aug 28, 2024
@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Aug 28, 2024
@poorna2152 poorna2152 removed needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Aug 28, 2024
@poorna2152 poorna2152 self-assigned this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants