Skip to content

Commit 3324032

Browse files
authored
[records] Allow "()" as an empty record expression. (#2535)
* [records] Allow "()" as an empty record expression. * Update version.
1 parent 73e0e57 commit 3324032

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

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

55
Status: Accepted
66

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

99
## Motivation
1010

@@ -122,6 +122,8 @@ not captured by the grammar. It is a compile-time error if a record has any of:
122122

123123
* Only one positional field and no trailing comma.
124124

125+
* No fields and a trailing comma. *The expression `(,)` isn't allowed.*
126+
125127
* A field named `hashCode`, `runtimeType`, `noSuchMethod`, or `toString`.
126128

127129
* A field name that starts with an underscore.
@@ -138,8 +140,7 @@ var number = (1); // The number 1.
138140
var record = (1,); // A record containing the number 1.
139141
```
140142

141-
There is no syntax for a zero-field record expression. Instead, there is a
142-
static constant `empty` on `Record` that returns the empty record.
143+
The expression `()` refers to the constant empty record with no fields.
143144

144145
### Record type annotations
145146

@@ -347,8 +348,8 @@ fields are) and collection literals.
347348
### Constants
348349

349350
Record expressions can be constant and potentially constant expressions. A
350-
record expression is a compile-time constant expression if and only if all its
351-
field expressions are compile-time constant expressions.
351+
record expression is a compile-time constant expression if and only if all of
352+
its field expressions are compile-time constant expressions.
352353

353354
*This is true whether the expression occurs in a constant context or not, which
354355
means that a record expression can be used directly as a parameter default value
@@ -587,6 +588,10 @@ covariant in their field types.
587588

588589
## CHANGELOG
589590

591+
### 1.13
592+
593+
- Introduce `()` syntax for empty record expressions and remove `Record.empty`.
594+
590595
### 1.12
591596

592597
- Include record types in `typeNotVoid`. This allows them to appear in `is` and

0 commit comments

Comments
 (0)