Ballerina-lang: Use of `start` allowed with error constructor

Created on 10 Apr 2020  路  3Comments  路  Source: ballerina-platform/ballerina-lang

Consider the following program:

import ballerina/io;

public function main() {
    error e = start error("Test");
    io:println(e);
}

The above compiles and runs fine and prints the following:

error Test

However, as per the spec, the above should not have been allowed:

start-action := [annots] start (function-call-expr|method-call-expr|remote-method-call-action)

CompilerSwanLakeDump TeaCompilerFE TypBug TypSpecDeviation

Most helpful comment

Ah great! But the error message itself is a bit problematic. IINM, we got rid of "functional constructors". In this case, the proper term is "error constructor". Check with @rdhananjaya as well.

All 3 comments

Seems this is fixed. Output with slp6-snapshot

Compiling source
    test.bal
ERROR [test.bal:(4:15,4:34)] use of 'start' not allowed with functional constructor 'error()'
error: compilation contains errors

Ah great! But the error message itself is a bit problematic. IINM, we got rid of "functional constructors". In this case, the proper term is "error constructor". Check with @rdhananjaya as well.

Ah great! But the error message itself is a bit problematic. IINM, we got rid of "functional constructors". In this case, the proper term is "error constructor". Check with @rdhananjaya as well.

+1 for error constructor

Was this page helpful?
0 / 5 - 0 ratings