#Does type inclusions in records resolve the redeclared fields

1 messages · Page 1 of 1 (latest)

solid abyss
#

I have the following code:

type A record {|
    string a;
    int b;
|};

type B record {|
    string a;
    float c;
|};

type C record {|
    *A;
    *B;
    decimal d;
|};

It gives the following error: redeclared symbol 'a'. When combing the fields, does not it resolve the redeclared fields?

thick mortar
#

I think it should be an error

It is an error if a record-type-descriptor has two or more record-type-inclusions that include an individual-field-descriptor with the same name, unless those individual-field-descriptors are overridden by an individual-field-descriptor in the including record-type-descriptor.

This is what mention in the spec regarding this scenario

solid abyss
#

I see, I think this statement is added in order to resolve the conflicts in the type when a same field is added via different records. (Correct me if I am wrong)

But here the type of the redeclared field is same in both records. So isn't it enough to resolve the conflicts