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.
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).
Most helpful comment
@CyrusNajmabadi I think you misread the expected vs actual behavior.