consulo / consulo-csharp

Languages: C#
Apache License 2.0
50 stars 6 forks source link

Named argument doesn't work well when used on argument with `params` keyword #522

Closed NIA closed 6 years ago

NIA commented 6 years ago

Example:

    public class TempTest {

        public int funcWithParamsArray(int i, params int[] paramsArray) {
            return i + paramsArray[0];
        }

        public void foo() {
             // works well
            int res = funcWithParamsArray(2, 3);

            // error in Consulo, but Visual Studio and Mono compiler accept this
            int res1 = funcWithParamsArray(2, paramsArray: 3); 
        }
    }

image

Ok, I can agree that this may be not a very good practice to write such code, and I don't know what C# specification says about this, but Visual Studio 2015, Rider 2017.3 and Unity's compiler (2017.2.0f3) definitely allow such code, I checked this: image image image

But it would be wrong to write two numbers (like paramsArray: 3, 4), because theyt would be parsed as different arguemnts and cause error (saying that named arguments should not precede positional) in all aforementioned tools, and Consulo does this correctly, too.