Ballerina-lang: Compiler fails with NPE

Created on 7 Dec 2019  路  3Comments  路  Source: ballerina-platform/ballerina-lang

Description:
Compiler fails with NPE on attached code.

Steps to reproduce:
Compile attached code

Affected Versions:
Ballerina 1.0.5

OS, DB, other environment details and versions:
Windows 10, JDK jdk1.8.0_231, IntelliJ

Ballerina.toml.txt

listener.bal.txt
ballerina-internal.log

AreCompiler PrioritBlocker TeaCompilerFE TypBug

Most helpful comment

Wow, that was fast response. Thanks !

All 3 comments

@mgabalins the bad, sad error seems to be occurring when attempting to log a compilation error for duplicate keys when creating a record value.

This happens when creating the record value in L154-L159, where reqStatus is first specified in L157 and then repeated in L159.

      rez = {
           reqCorrelationId : "",                                // Unknown, since read failed
           reqCorgid        : "",
           reqStatus        : "JDBCERROR",                       // Request dequeue status
           reqPayload       : "",
           reqStatus        : ""
      };

Removing one of the two will fix the compilation error.

      rez = {
           reqCorrelationId : "",                                // Unknown, since read failed
           reqCorgid        : "",
           reqStatus        : "JDBCERROR",                       // Request dequeue status
           reqPayload       : ""
      };

We will fix the issue causing the bad, sad error.

Wow, that was fast response. Thanks !

Simpler code to reproduce.

type Foo record {|
    string s;
    int a;
|};

public function main() {
    // // Fails with invalid usage of record literal: duplicate key 's'.
    // Foo f = {
    //     s: "foo",
    //     a: 1,
    //     s: "foo"
    // };

    // Bad, sad error.
    Foo f;
    f = {
        s: "foo",
        a: 1,
        s: "foo"
    };
}
Was this page helpful?
0 / 5 - 0 ratings