dart-lang / dart-lang/language
Allow trailing commas in constructor initializer lists and generic type lists
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Trailing comma is supported in many places like argument lists, list entries, etc. However there are still places where it is not supported by would be beneficial:
1. Constructor initializer:
```
PlatformInstance()
:
_environment = Platform.environment,
_executable = Platform.executable,
_executableArguments = Platform.executableArguments,
_localeName = Platform.localeName,
_localHostname = Platform.localHostname,
_numberOfProcessors = Platform.numberOfProcessors,
_operatingSystem = Platform.operatingSystem,
_operatingSystemVersion = Platform.operatingSystemVersion,
_packageConfig = Platform.packageConfig,
_pathSeparator = Platform.pathSeparator,
_resolvedExecutable = Platform.resolvedExecutable,
_script = Platform.script,
_version = Platform.version, // <========
;
```
2. Generic type lists:
```
class GenericClass<
A,
B extends SomeClass,
C extends AnotherClass, // <=======
> {
}
```
Proposal: to allow trailing comma in these cases to minimize changes when adding or moving new lines there.
Contributor guide
Research direction
Start with issue #1402 and compare its two examples with the existing trailing-comma cases described in the issue. Determine the language changes needed for constructor initializer lists and generic type lists, then verify that both forms accept a final comma without changing other syntax rules.
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