@@ -4,7 +4,7 @@ Author: Bob Nystrom
4
4
5
5
Status: Accepted
6
6
7
- Version 1.11 (see [ CHANGELOG] ( #CHANGELOG ) at end)
7
+ Version 1.12 (see [ CHANGELOG] ( #CHANGELOG ) at end)
8
8
9
9
## Motivation
10
10
@@ -174,6 +174,10 @@ typeNotFunction ::= 'void' // Existing production.
174
174
| recordType '?'? // New production.
175
175
| typeNotVoidNotFunction // Existing production.
176
176
177
+ typeNotVoid ::= functionType '?'? // Existing production.
178
+ | recordType '?'? // New production.
179
+ | typeNotVoidNotFunction // Existing production.
180
+
177
181
// New rules:
178
182
recordType ::= '(' recordTypeFields ',' recordTypeNamedFields ')'
179
183
| '(' recordTypeFields ','? ')'
@@ -189,9 +193,7 @@ recordTypeNamedField ::= metadata type identifier
189
193
190
194
* The grammar is exactly the same as ` parameterTypeList ` in function types but
191
195
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.*
195
197
196
198
The type ` () ` is the type of an empty record with no fields.
197
199
@@ -413,6 +415,17 @@ value. Notice that if the `identical()` returns `true` on two records, they must
413
415
be structurally equivalent, but unlike for non-records, the ` identical() `
414
416
function can also return ` false ` for structurally equivalent records.*
415
417
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
+
416
429
## Runtime semantics
417
430
418
431
The fields in a record expression are evaluated left to right. * This is true
@@ -574,6 +587,13 @@ covariant in their field types.
574
587
575
588
## CHANGELOG
576
589
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
+
577
597
### 1.11
578
598
579
599
- Revert back to disallowing private field names in records.
0 commit comments