Version Used: 5.7.0-1.26217.5 (77dc97b)
Steps to Reproduce:
.NET Lab
using System.Collections.Generic;
using System.Runtime.CompilerServices;
class C
{
unsafe void M1()
{
int p = *default(int*); // no error
ref int outside = ref Unsafe.NullRef<int>();
{
int local = 1;
outside = ref local; // warning
}
}
unsafe IEnumerable<int> M2()
{
int p = *default(int*); // error
ref int outside = ref Unsafe.NullRef<int>();
{
int local = 1;
outside = ref local; // warning
}
yield return 1;
}
}
Expected Behavior: the ref safety violation in M2 should be an error, since it's in a safe context
Actual Behavior: it's a warning (it thinks it's in unsafe context since M2 is declared as unsafe but doesn't consider that it's an iterator)
Version Used: 5.7.0-1.26217.5 (77dc97b)
Steps to Reproduce:
.NET Lab
Expected Behavior: the ref safety violation in
M2should be an error, since it's in a safe contextActual Behavior: it's a warning (it thinks it's in
unsafecontext sinceM2is declared asunsafebut doesn't consider that it's an iterator)