Skip to content

Commit 7457b15

Browse files
committed
[records] Revert back to disallowing private named fields.
1 parent 468fe2b commit 7457b15

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

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

55
Status: Accepted
66

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

99
## Motivation
1010

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

125125
* A field named `hashCode`, `runtimeType`, `noSuchMethod`, or `toString`.
126126

127+
* A field name that starts with an underscore.
128+
127129
* A field name that collides with the synthesized getter name of a positional
128130
field. *For example: `('pos', $0: 'named')` since the named field '$0'
129131
collides with the getter for the first positional field.*
@@ -213,6 +215,8 @@ It is a compile-time error if a record type has any of:
213215
* A named field named `hashCode`, `runtimeType`, `noSuchMethod`, or
214216
`toString`.
215217

218+
* A field name that starts with an underscore.
219+
216220
* A field name that collides with the synthesized getter name of a positional
217221
field. *For example: `(int, $0: int)` since the named field '$0' collides
218222
with the getter for the first positional field.*
@@ -264,15 +268,8 @@ structural, not nominal. Records produced in unrelated libraries have the exact
264268
same static type if they have the same shape and their corresponding fields have
265269
the same types.
266270

267-
If a field name starts with an underscore, it is private and is only accessible
268-
in the library where it appears. The records `(_foo: 1)` and `(_foo: 1)`
269-
appearing in different libraries do *not* have the same shape because each
270-
`_foo` is considered a distinct name. Likewise, the record types `({int _foo})`
271-
and `({int _foo})` are not the same type if those annotations appear in
272-
different libraries.
273-
274-
The order of named fields is not significant. The record types `({int a, int b})`
275-
and `({int b, int a})` are identical to the type system and the runtime. (Tools
271+
The order of named fields is not significant. The record types `{int a, int b}`
272+
and `{int b, int a}` are identical to the type system and the runtime. (Tools
276273
may or may not display them to users in a canonical form similar to how they
277274
handle function typedefs.)
278275

@@ -582,6 +579,10 @@ covariant in their field types.
582579

583580
## CHANGELOG
584581

582+
### 1.11
583+
584+
- Revert back to disallowing private field names in records.
585+
585586
### 1.10
586587

587588
- Allow private named fields in records (#2387).

0 commit comments

Comments
 (0)