Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strangeness in interaction between record openness, optionality and subtyping #301

Open
jclark opened this issue Aug 14, 2019 · 0 comments
Labels
design/usability Design does not work well for some tasks lang Relates to the Ballerina language specification

Comments

@jclark
Copy link
Collaborator

jclark commented Aug 14, 2019

There is also a complication in the interaction between openness and optionality. Suppose we have

type ClosedDate record {|
   int year;
   int month;
   int day;
|};

type ExClosedDate record {|
   *ClosedDate;
   int dayOfWeek?;
|};

type OpenDate record {
   *ClosedDate;
};

type ExOpenDate record {
   *ExClosedDate;
};

Then ClosedDate is a proper subtype of ExClosedDate, but ExOpenDate is a proper subtype of OpenDate. It feels rather unintuitive that the subtyping relationship gets swapped in this way.

@jclark jclark added lang Relates to the Ballerina language specification design/usability Design does not work well for some tasks labels Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design/usability Design does not work well for some tasks lang Relates to the Ballerina language specification
Projects
None yet
Development

No branches or pull requests

1 participant