dart-lang / dart-lang/language
[Question] Using `==` directive vs. in constant Set literal
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
I have a trouble with understanding when `==` should be invoked, and when it is allowed.
```dart
const d = dynamic;
const i = int;
void main() {
const a = {d, i};
const b = d == i;
}
```
We report a compile-time error for `b`, because `==` can only be invoked on `Null`, `bool`, `int`, `double`, or `String`.
So, when we attempt to evaluate it, we detect and error, and throw an exception.
But at the same time the specification for constant Sets says:

Currently implementations consider `{d, i}` to be OK.
But why? It invokes `==` just like `d == i`, except that it does it implicitly.
Contributor guide
Research direction
Read the constant-set specification alongside the examples using `const d = dynamic`, `const i = int`, `{d, i}`, and `d == i`. Determine whether the differing treatment of implicit equality in constant sets is intentional, then clarify the specification or document the resolution so the two cases are consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100