For the Dafny code below, the Dafny compiler generates illegal C# code:
``
method F() returns(x:int)
ensures x == 6;
{
x := 5;
x := (var y := 1; y + x);
}
method Main()
{
var x := F();
print x;
}
``
The C# compiler generates the following error:
``
Cannot use ref or out parameter 'x' inside an anonymous method, lambda expression, or query expression
``
``
method F() returns(x:int)
ensures x == 6;
{
x := 5;
x := (var y := 1; y + x);
}
method Main()
{
var x := F();
print x;
}
``
The C# compiler generates the following error:
``
Cannot use ref or out parameter 'x' inside an anonymous method, lambda expression, or query expression
``