ballerina-platform / ballerina-spec

Ballerina Language and Platform Specifications
Other
167 stars 53 forks source link

Intersection types in included record parameters and record type inclusion #1224

Open MaryamZi opened 1 year ago

MaryamZi commented 1 year ago

Description:

The spec says

for included record parameters

The type-reference in an included-record-param must refer to a type defined by a record-type-descriptor.

for record type inclusion

The type-reference must reference a type described by a record-type-descriptor.

Therefore, the following are not allowed (in jBallerina) at the moment, but can't we allow these?

type Record readonly & record {|
    int i;
    string j;
|};

function fn(*Record t) { // compilation error at the moment

}

type Record2 record {| 
    *Record; // compilation error at the moment
    byte i;
|};
jclark commented 1 year ago

We should allow this.