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

Array of pointer not diagnosed #34779

Open
gafter opened this issue Apr 5, 2019 · 2 comments
Open

Array of pointer not diagnosed #34779

gafter opened this issue Apr 5, 2019 · 2 comments

Comments

@gafter
Copy link
Member

gafter commented Apr 5, 2019

As observed by #34693 (comment) the following program fails to report the incorrect use of a pointer type after #34739

public class A {
    public class B {}
}

public class C<T> : A {
    public C<string*[]>.B field; // error: pointer to managed type
}

here is another case that isn't properly diagnosed:

public class A
{
    public class Inner {}
}

public class B<T> : A where T : unmanaged
{
}

public class C
{
    B<string>.Inner field;
}
@RikkiGibson
Copy link
Contributor

RikkiGibson commented Apr 5, 2019

I wasn't precise enough in my comment there. As far as I can tell, the first case with string* is diagnosed because the "unmanaged constraint" on pointers is checked at the time C<string*[]> is bound--and we have a test for this. The second case however isn't caught because we check the type parameter's constraints after field types are bound.

As @cston pointed out (I think only offline?) there is a similar bug with method return types in 2.9.0 and today:

public class A
{
    public class Inner {}
}

public class B<T> : A where T : unmanaged
{
}

public class C
{
    B<string>.Inner M() => throw null;
}

This bug is likely to be present in every case where constraints are checked after binding instead of during binding.

@gafter gafter added this to the Backlog milestone Apr 5, 2019
@gafter
Copy link
Member Author

gafter commented Apr 5, 2019

In that case, moving to Backlog.

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

2 participants