Support trailing comma in various comma-separated lists.
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
Today it is not legal to do the following:
```vb
Public Sub Foo(
Arg1 As Integer,
Arg2 As String, '<--- compiler complains here.
)
Dim MyArray = {
"one",
"two", '<--- compiler complains here.
}
Dim person = New CPerson() With {
.Name = "foo",
.Age = 100, '<--- compiler complains here.
}
End Sub
```
The comma-seperated list of arguments, array elements and field initialisers all have a trailing comma in the above code and the compiler reports an error saying an identifier is required.
Supporting this appears to be a small syntax change which would help dramatically when editing code using commands such as `DuplicateLine` and `MoveLineUp` and `MoveLineDown` which always results in a syntax error when touching the last item in comma-seperated list. For example, starting with this valid code:
```vb
Dim MyArray = {
"one",
"two"
}
```
If you execute the `MoveLineUp` editing command on the line containing string `"two"`, you end up with the following which is a syntax error today:
```vb
Dim MyArray = {
"two" '<-- comma needed here.
"one", '<-- comma not allowed here.
}
```
I've justed tried this in C#, it works for the array and object initialiser but not on method declarations:
```c#
public class Class1
{
public string name;
public int age;
private string[] myarray = {
"one",
"two", //<--- this is OK.
};
private Class1 foo = new Class1() {
name = "foo",
age = 12, //<--- this is OK.
};
private void Foo(
int Arg1,
int Arg2, //<--- this breaks.
) {
}
}
```
CC: @AnthonyDGreen
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.