Open IS4Code opened 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @cston See info in area-owners.md if you want to be subscribed.
Author: | IllidanS4 |
---|---|
Assignees: | - |
Labels: | `area-Microsoft.CSharp`, `untriaged` |
Milestone: | - |
Issue still exists on .NET 8.
Description
When a method is called with a
dynamic
argument, theunmanaged
constraint (and likely other new constraints) is not taken into account when the overload is being picked.Reproduction Steps
Create a method like
N<T>(T value) where T : unmanaged
and call it with adynamic
-typed instance of a non-unmanaged type. For example:Expected behavior
The overload with
where T : unmanaged
should not be picked, as it violates the constraint and is inconsistent with C#.Actual behavior
where T : unmanaged
is treated aswhere T : struct
in the DLR, and is picked even for a non-unmanaged type.Regression?
No response
Known Workarounds
No response
Configuration
Tested on .NET 8, 6, and 5.
Other information
No response