Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref ternary must match val-escapes on its branches (not ref escapes) #22197

Closed
VSadov opened this issue Sep 19, 2017 · 0 comments
Closed

ref ternary must match val-escapes on its branches (not ref escapes) #22197

VSadov opened this issue Sep 19, 2017 · 0 comments

Comments

@VSadov
Copy link
Member

VSadov commented Sep 19, 2017

The spec and implementation need to be updated. The following should fail

public class C
{
    bool flag1 = true;
    bool flag2 = false;

    public void M(ref Span<int> global)
    {
        Span<int> local = stackalloc int[10];

        ref var r1 = ref (flag1 ? ref global : ref local);
        ref var r2 = ref (flag2 ? ref global : ref local);

	// same as         global = local;   which would be an error.
       // but we can’t fail here, since r1 and r2 are basically the same, 
       // so should fail when making r1 and r2 above.
        r1 = r2;   

        // it would require val-escape scopes for r1 and r2 be different.
        // easier to say that val-escape must match
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant