dart-lang / dart-lang/language
Add more tests for CONST_CANONICAL_TYPE
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Recently I discovered that **dart2js** was canonicalizing `const []` and `const []` to the same object.
This canonicalization is incorrect [1] and only recently showed up a few co19 tests for patterns.
It would be helpful if there was better test coverage. On the dart2js team we missed implementing CONST_CANONICAL_TYPE as it was not flagged by test coverage.
Ideally, coverage would include:
- Various top-types like `dynamic`, `Object?`, `Object*`, `FutureOr<...>` etc
- Various other types that should be distinguished or be the same (e.g. `Null` and `Never?`)
- Inner types (`const >[]`) and other constructs where the CONST_CANONICAL_TYPE has an effect on deep structure (function parameters etc).
- The tests should cover literal syntax as `const []`, `const {}`, and `const {}` go through different paths.
- The tests should cover classes with `const` constructors declared in both legacy and nnbd libraries.
- The test should cover constants declared in both legacy and nnbd libraries, used from legacy and nnbd libraries.
It is not clear at this point if there is an interaction between CONST_CANONICAL_TYPE and const Record instances.
[1] (https://github.com/dart-lang/language/blob/master/accepted/2.12/nnbd/feature-specification.md#constant-instances)
/cc @eernstg
Contributor guide
Research direction
Start by locating the existing co19 pattern tests and the dart2js handling of CONST_CANONICAL_TYPE. Review how constant list, set, and map literals and legacy versus nnbd libraries are currently tested. Done means coverage distinguishes the listed top types, nested types, function parameters, literal forms, library modes, and any relevant const Record interaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100