-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow trailing commas in parameter and argument lists. #26644
Comments
Can you have a trailing comma after the '}' in a parameter list? eg: void foo(
String x,
List y,
{bool z: true},
) {
} |
@hterkelsen It handles the cases where you move the last parameter somewhere else (leaving a dangling comma on the previous line and, maybe, missing a comma after the moved parameter in the new position), or where you add a new last parameter after the existing one (now missing a comma on the previous line). In your example, you put the single optional parameter on a line including the braces. You can only move that line to the end of another parameter list, so there is no advantage to allowing a comma after it. Basically the feature is for anywhere where you could write |
Adds parser support for trailing commas in parameter and argument lists. Meta-tracking issue: #26644 In most cases, errors were preserved (and tested) across parsers with and without the flag set. (The exception is a formal paramater list with an extra comma, like `(a,,)` which with trailing comma support enabled only reports a missing identifier; needless to say this is captured in a test and is up for further debate.) Amazingly (and for better or worse), turning this option on in the parser (`parseTrailingCommas = true`) produces NO errors in the analyzer and server tests. BUG=26647 R=brianwilkerson@google.com Review URL: https://codereview.chromium.org/2116853002 .
For the VM and dart2js, do we need to use a flag to opt-in to the feature? |
No, it should be enabled by default. On Tue, Jul 26, 2016, 1:18 PM Seth Ladd notifications@github.com wrote:
|
From discussion in #26649 the style guide update will follow later, and from discussion in release meeting this feature is indeed complete for 1.19, so closing. |
Updating changelog in https://codereview.chromium.org/2220963002/ |
To improve the maintainability of long argument and parameter lists, we allow the final argument or parameter to be followed by an optional comma. This allows a style where each argument or parameter is written on a line by itself, and moving one item up or down or between functions doesn't require special handling of the final item.
This matches the existing behavior for list and map literals and enum class declarations.
To be precise:
Tracking bugs for individual tasks:
For later:
The text was updated successfully, but these errors were encountered: