Skip to content

[Bug]: Compiler crashes when a function is followed by an invalid resource function #43788

Open
@nipunayf

Description

@nipunayf

Description

$title with the following error message.

Details

[2025-02-03 00:26:45,472] SEVERE {b7a.log.crash} - Syntax kind is not supported: SEMICOLON_TOKEN 
java.lang.RuntimeException: Syntax kind is not supported: SEMICOLON_TOKEN
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:2422)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:534)
        at io.ballerina.compiler.syntax.tree.Token.apply(Token.java:116)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.createRawTemplateLiteral(BLangNodeBuilder.java:5544)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:2478)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:534)
        at io.ballerina.compiler.syntax.tree.TemplateExpressionNode.apply(TemplateExpressionNode.java:59)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.createActionOrExpression(BLangNodeBuilder.java:5502)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.createExpression(BLangNodeBuilder.java:5475)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.initializeBLangVariable(BLangNodeBuilder.java:3090)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:703)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:534)
        at io.ballerina.compiler.syntax.tree.ModuleVariableDeclarationNode.apply(ModuleVariableDeclarationNode.java:71)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:676)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.transform(BLangNodeBuilder.java:534)
        at io.ballerina.compiler.syntax.tree.ModulePartNode.apply(ModulePartNode.java:54)
        at org.wso2.ballerinalang.compiler.parser.BLangNodeBuilder.accept(BLangNodeBuilder.java:574)
        at io.ballerina.projects.DocumentContext.compilationUnit(DocumentContext.java:120)
        at io.ballerina.projects.ModuleContext.compileInternal(ModuleContext.java:393)
        at io.ballerina.projects.ModuleCompilationState$1.compile(ModuleCompilationState.java:45)
        at io.ballerina.projects.ModuleContext.compile(ModuleContext.java:354)
        at io.ballerina.projects.PackageCompilation.compileModulesInternal(PackageCompilation.java:211)
        at io.ballerina.projects.PackageCompilation.compileModules(PackageCompilation.java:195)
        at io.ballerina.projects.PackageCompilation.compile(PackageCompilation.java:102)
        at io.ballerina.projects.PackageCompilation.from(PackageCompilation.java:97)
        at io.ballerina.projects.PackageContext.getPackageCompilation(PackageContext.java:269)
        at io.ballerina.projects.Package.getCompilation(Package.java:159)
        at io.ballerina.projects.Package.runCodeGeneratorPlugins(Package.java:366)
        at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:158)
        at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
        at io.ballerina.cli.cmd.RunCommand.execute(RunCommand.java:303)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:63)

Steps to Reproduce

Compile the following Ballerina source code.

// Resource function (used in services)
resource function get greeting() returns string {
    return "Hello, World!";
}

// Function with record type parameter
public function processUser(record {| string name; int age; |} user) returns string {
    return string `${user.name} is ${user.age} years old`;
}

Affected Version(s)

2201.11.0

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

Metadata

Metadata

Assignees

Labels

Area/CompilerFix/CrashAll issues caused by NPE, CCE, etcTeam/CompilerFEAll issues related to Language implementation and Compiler, this exclude run times.Type/BugneedTriageThe issue has to be inspected and labeled manuallyuserCategory/Compilation

Type

No type

Projects

Status

On Hold

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions