dart-lang / dart-lang/language
Disallow `var` or `final` in front of initializing or super parameters.
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
The grammar today allows a constructor like `C(var this.x, final this.y)`.
They do so because we reuse grammar, so we end up with `` for the type.
The `var` and `final` make no difference, they do not affect the variable being initialized, they do not affect the implicit variable that is visible in the initializer list (that one's always `final`). In short, it's noise.
I also doubt anyone ever uses the syntax, so how about just disallowing it. The grammar of parameters might become a little less orthogonal, or we can simply do it in prose and say that it's a compile-time error if the `?` production preceding a `this.` or `super.` parameter is not just a `?`.
Contributor guide
Research direction
Start by locating the parameter grammar and specification prose for initializing and super parameters. Check how the existing production applies before this. and super. parameters, then define the compile-time-error wording or grammar change and verify that var this.x and final this.y are rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100