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]: Crashes with NPE when cyclic record field references #42526

Open
gabilang opened this issue Apr 10, 2024 · 0 comments
Open

[Bug]: Crashes with NPE when cyclic record field references #42526

gabilang opened this issue Apr 10, 2024 · 0 comments
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation

Comments

@gabilang
Copy link
Contributor

Description

$title

Steps to Reproduce

type Person record {|
    string name;
    int age?;
    Student ...;
|};

type Student record {|
    *Person;
    int studentId;
    string code?;
|};

Output:

[2024-04-10 10:46:44,542] SEVERE {b7a.log.crash} - Cannot read field "scope" because "env" is null 
java.lang.NullPointerException: Cannot read field "scope" because "env" is null
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolResolver.transform(SymbolResolver.java:1603)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolResolver.transform(SymbolResolver.java:149)
        at org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType.apply(BLangUserDefinedType.java:87)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolResolver.resolveTypeNode(SymbolResolver.java:541)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolResolver.resolveTypeNode(SymbolResolver.java:520)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter.resolveRestField(SymbolEnter.java:3939)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter.resolveRestField(SymbolEnter.java:3954)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter.defineReferencedFieldsOfRecordTypeDef(SymbolEnter.java:3918)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.defineFields(TypeResolver.java:293)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDesc(TypeResolver.java:1074)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDesc(TypeResolver.java:711)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDefinition(TypeResolver.java:543)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDesc(TypeResolver.java:1624)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDesc(TypeResolver.java:729)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDesc(TypeResolver.java:684)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDesc(TypeResolver.java:1054)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDesc(TypeResolver.java:711)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.resolveTypeDefinition(TypeResolver.java:543)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.TypeResolver.defineBTypes(TypeResolver.java:235)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter.defineConstructs(SymbolEnter.java:430)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter.visit(SymbolEnter.java:357)
        at org.wso2.ballerinalang.compiler.tree.BLangPackage.accept(BLangPackage.java:167)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter.defineNode(SymbolEnter.java:313)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter.definePackage(SymbolEnter.java:289)
        at io.ballerina.projects.ModuleContext.compileInternal(ModuleContext.java:433)
        at io.ballerina.projects.ModuleCompilationState$1.compile(ModuleCompilationState.java:45)
        at io.ballerina.projects.ModuleContext.compile(ModuleContext.java:383)
        at io.ballerina.projects.PackageCompilation.compileModulesInternal(PackageCompilation.java:208)
        at io.ballerina.projects.PackageCompilation.compileModules(PackageCompilation.java:192)
        at io.ballerina.projects.PackageCompilation.compile(PackageCompilation.java:99)
        at io.ballerina.projects.PackageCompilation.from(PackageCompilation.java:94)
        at io.ballerina.projects.PackageContext.getPackageCompilation(PackageContext.java:242)
        at io.ballerina.projects.Package.getCompilation(Package.java:150)
        at io.ballerina.projects.Package.runCodeGeneratorPlugins(Package.java:319)
        at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:142)
        at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
        at io.ballerina.cli.cmd.BuildCommand.execute(BuildCommand.java:288)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)

Affected Version(s)

2201.8.x

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

@gabilang gabilang added Type/Bug Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Apr 10, 2024
@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Apr 10, 2024
@gabilang gabilang removed the needTriage The issue has to be inspected and labeled manually label Apr 10, 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 userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

2 participants