dart-lang / dart-lang/language
Specify the context type for the index in an increment/decrement operation
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
The context type for an expression of the form `e1[e2]++`, `e1[e2]--`, `++e1[e2]`, `--e1[e2]` is apparently not specified.
In the case where the corresponding operator declarations have parameter types `T1` and `T2` for the index, the most general type that would work is the greatest lower bound of `T1` and `T2`, so we would most likely use the standard lower bound (which is an approximation of the greatest lower bound).
```dart
class C {
T0 operator[](T1 index) ...
operator[]=(T2 index, T3 value) ...
}
X whatever() {
print(X);
throw 0;
}
void main() {
C()[whatever()]++; // Prints the standard lower bound of `T1` and `T2`.
}
```
Contributor guide
Research direction
Start with the issue's four increment/decrement forms and the example declarations for operator[] and operator[]=. Review the language specification rules for indexed assignment and operator typing, then determine whether the standard lower bound of T1 and T2 gives the required context type. Done means the specification states the rule unambiguously and the example has the expected type.
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
- Mostly clear
- Newbie friendliness
- 35/100