-
Notifications
You must be signed in to change notification settings - Fork 4k
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
The type parameters aren't correctly inferred on function pointers #50096
Comments
I cannot reproduce this on VS 16.9 Preview 2 with the code snippet provided, and this project file: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
</Project> @SunnieShine, is there anything else special about your environment? |
@SunnieShine I've been unable to replicate this issue, and am closing it out. If you have more info, please comment and we can reopen. |
Hmm, actually, the original snippet has the type parameters there, I misread it. I can reproduce it if I modify the snippet. |
dotnet#43041 implemented exact inference of function pointer parameters and bounds only, and left a few errors in our tests that needed to be handled. This is also the cause of dotnet#50096. This implements bounds inference, using the same variance rules that function pointer to function pointer conversions do. I still need to spec the rules here, and may need to make a couple of adjustments around handling of delegate*->void* in bounds inference. At least initially, this isn't supported, but I'll work out what the correct rules should be when I spec it and update this PR accordingly. Fixes dotnet#50096.
@333fred I'm so sorry for late to read your reply. The real problem is that the type parameters can't be omitted. To be honest, I have the same configuration with yours: <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
</PropertyGroup> Snapshots: |
As I mentioned, I misread your initial snippet. I have a draft out now that should fix the issue. |
:) |
Fixed in #50249 |
Version Used:
VS 16.9 Preview 2
Steps to Reproduce:
Type code
The code segment
should specify type parameters
<int, string>
.Expected Behavior:
Because of the type parameters can be inferred from function pointers, so we can omit them:
Actual Behavior:
An compiler error CS0411 raised: Try to specify type parameters.
The text was updated successfully, but these errors were encountered: