dart-lang / dart-lang/language
Should record types of interest be compositional?
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
If you do `if (x is int)`, we make `int` *and `int?`* types of interest for `x`.
If you do `if (pair is (int, int))`, should we also make `(int?, int?)`, `(int, int?)` and `(int?, int)` types of interest for `pair` (and the corresponding nullable record types)?
Or in general, if a record type is of interest, is nullability-variations on every field also of interest, including for the declared type.
The answer is probably "no", but maybe someone has a use-case where it makes sense, so putting the question out there.
For example:
```dart
void use((int, int) pair) { ... }
(int?, int?)? maybePair = ...; // Maybe nothing at every position, or at all.
if (maybePair == null) {
maybePair = (1, 2); // Assignment-promotes to (int?, int?) I assume, but not (int, int).
use(maybePair); // Won't work.
} else {
maybePair = (maybePair.$1 ?? 0, maybePair.$2 ?? 0); // No promotion from (int?, int?)
use(maybePair);
}
// ...
```
Contributor guide
Research direction
Start with the issue's examples of record types, nullable fields, and type promotion. No files or tests are named, so first determine the intended language rule and whether existing record-type interest behavior is documented elsewhere. Done means the nullability-composition question has a decided specification outcome and corresponding implementation scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100