-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Dynamic invocation of a local function succeeds unexpectedly when there is a ref kind mismatch for a 'dynamic' argument. #71399
Comments
There is also an existing test
|
It looks like the behavior is caused by a combination of two parts: roslyn/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs Lines 3898 to 3905 in 182e829
roslyn/src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs Lines 755 to 771 in 182e829
If the spec violation in roslyn/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs Lines 8787 to 8812 in 182e829
The scenario fails to compile with the following errors:
Do we really want to keep this spec violation in the compiler? |
I'm pretty warry about changing any |
While there is a risk of breaking something. In this scenario, we know whether we are dealing with a COM API.
It is true that changing the behavior is likely to move the failure for legacy scenarios to compile time (vs. runtime). However, is that really that big of a break? |
The relaxation for COM APIs is handled separately here roslyn/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs Lines 3313 to 3320 in 182e829
|
LDM discussed this issue on January 29th, 2024 and the decision was to go ahead with the fix without dependency on targeted language version. However, the breaking change should be documented. |
Observed (https://sharplab.io/#v2:EYLgtghglgdgNAFxAJwK4wD4AEBMACAWQFgAoAb1LyrywEYA2GgFkOhgAoBKS6ik6gXgAmATxgQwUAMZ4oeALx5aAbh6C8awQBsA9lIhb2UTqv7qatAHR0AnEZOaBBAKZhgz5PdPmL12neNvc0dqLBZdfUNkZwAzWRgEPAAPTjJkgGp05TwAX008sypNOkYwwld3T2i42ESUtKTM7IKcoA==):
Expected:
Compilation error for
local(i);
.The text was updated successfully, but these errors were encountered: