Roslyn: Ref declaration expressions shouldn't be parsed in out arguments

Created on 26 Apr 2018  路  5Comments  路  Source: dotnet/roslyn

Version Used:

Microsoft Visual Studio Professional 2017 Preview (2)
Version 15.7.0 Preview 4.0
VisualStudio.15.Preview/15.7.0-pre.4.0+27617.1
Microsoft .NET Framework
Version 4.7.02556

Steps to Reproduce:

Compile and run the following code

class C
{
  public static void Main()
  {
    M();
  }
  public static void M()
  {
    M(out ref readonly int x);
    ref readonly int y = ref x;
    x = 6;
  }
  public static void M(out int q)
  {
    q = 0;
  }
}

Expected Behavior:

Compilation error for M(out ref readonly int x)
Compilation error for x = 6; as it assigns 'readonly' ref.

Actual Behavior:

Code compiles and runs without errors.

3 - Working Area-Compilers Bug

Most helpful comment

@CyrusNajmabadi I think you misread the expected vs actual behavior.

All 5 comments

Sorry, i don't see anything in the language that would allow for this. Can you poitn to the part of the language spec that makes you think this would be legal?

If this is not part of the spec, and you would liek teh language to allow this, then can you please file a proposal over at dotnet/csharplang?

Thanks!

@CyrusNajmabadi I think you misread the expected vs actual behavior.

Yup! My bad. Swapped things in my head. Thanks. This is def strange :)

Tagging @jcouv for triage.

Note: I bucketed this issue in 15.8 because the bug bar for 15.7 is quite high at the moment.
Tagging @jaredpar to confirm.
I think fixing this would be a minor compat break in 15.8, but probably acceptable. This bug was likely introduced in 15.5 (with ref readonly work).

Was this page helpful?
0 / 5 - 0 ratings