Skip to content

Subtyping: Missing record fields must decode at type reserved for transitivity #131

@nomeata

Description

@nomeata

We currently have this rule:

<nat> not in <fieldtype>;*
record { <fieldtype>;* } <: record { <fieldtype'>;* } ~> f
------------------------------------------------------------------------------
record { <fieldtype>;* } <: record { <nat> : opt <datatype'>; <fieldtype'>;* }
  ~> \x.{f x with <nat> = null}

This gives record {} <: record { foo : opt bool }.

We also have record { foo : opt bool } <: record { foo : reserved } (by virtue of opt bool <: reserved).

By transitivity, we should have record {} <: record { foo : reserved }.

So it seems we need

<nat> not in <fieldtype>;*
record { <fieldtype>;* } <: record { <fieldtype'>;* } ~> f
------------------------------------------------------------------------------
record { <fieldtype>;* } <: record { <nat> : reserved; <fieldtype'>;* }
  ~> \x.{f x with <nat> = null}

as well.

(This uses null as an arbitrary representation for a reserved value. Woudn’t mind adding an explicit reserved to the textual representation and data model, that would be handy in other contexts as well.)

We could combine the two into a single rule by saying

<nat> not in <fieldtype>;*
record { <fieldtype>;* } <: record { <fieldtype'>;* } ~> f
opt empty <:  <datatype'>
------------------------------------------------------------------------------
record { <fieldtype>;* } <: record { <nat> : <datatype'>; <fieldtype'>;* }
  ~> \x.{f x with <nat> = null}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions