Skip to content

Commit 2a54bb6

Browse files
committed
[records] Add record types to typeNotVoid.
Also clarify that record types can't be superinterfaces or superclasses. Fix #2515.
1 parent bd66aac commit 2a54bb6

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

accepted/future-releases/records/records-feature-specification.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Author: Bob Nystrom
44

55
Status: Accepted
66

7-
Version 1.11 (see [CHANGELOG](#CHANGELOG) at end)
7+
Version 1.12 (see [CHANGELOG](#CHANGELOG) at end)
88

99
## Motivation
1010

@@ -174,6 +174,10 @@ typeNotFunction ::= 'void' // Existing production.
174174
| recordType '?'? // New production.
175175
| typeNotVoidNotFunction // Existing production.
176176
177+
typeNotVoid ::= functionType '?'? // Existing production.
178+
| recordType '?'? // New production.
179+
| typeNotVoidNotFunction // Existing production.
180+
177181
// New rules:
178182
recordType ::= '(' recordTypeFields ',' recordTypeNamedFields ')'
179183
| '(' recordTypeFields ','? ')'
@@ -189,9 +193,7 @@ recordTypeNamedField ::= metadata type identifier
189193

190194
*The grammar is exactly the same as `parameterTypeList` in function types but
191195
without `required`, and optional positional parameters since those don't apply
192-
to record types. A record type can't appear in an `extends`, `implements`,
193-
`with`, or mixin `on` clause, which is enforced by being a production in `type`
194-
and not `typeNotVoid`.*
196+
to record types.*
195197

196198
The type `()` is the type of an empty record with no fields.
197199

@@ -413,6 +415,17 @@ value. Notice that if the `identical()` returns `true` on two records, they must
413415
be structurally equivalent, but unlike for non-records, the `identical()`
414416
function can also return `false` for structurally equivalent records.*
415417

418+
### Uses
419+
420+
It is a compile-time error if a record type or a type alias that resolves to a
421+
record type is used in:
422+
423+
* An `extends` clause.
424+
* An `implements` clause.
425+
* A `with` clause.
426+
* An `on` clause on a mixin declaration. *A record type can be used as the
427+
`on` type in an extension declaration.*
428+
416429
## Runtime semantics
417430

418431
The fields in a record expression are evaluated left to right. *This is true
@@ -574,6 +587,13 @@ covariant in their field types.
574587

575588
## CHANGELOG
576589

590+
### 1.12
591+
592+
- Include record types in `typeNotVoid`. This allows them to appear in `is` and
593+
`as` expressions (which was always intended).
594+
595+
- Clarify that record types cannot be used as supertypes or superinterfaces.
596+
577597
### 1.11
578598

579599
- Revert back to disallowing private field names in records.

0 commit comments

Comments
 (0)