C# 14 - Simple Lambda Parameters With Modifiers - Inferred Type Arguments #9522
-
Hi, This is something else I ran into while playing around with the C# 14 preview: public static class Extensions
{
public delegate bool TrySelectDelegate<TSource, TResult>(TSource item, out TResult result);
public static IEnumerable<TResult> TrySelect<TSource, TResult>(
this IEnumerable<TSource> source,
TrySelectDelegate<TSource, TResult> trySelector)
{
foreach (var item in source)
{
if (trySelector(item, out var result))
{
yield return result;
}
}
}
public static void Test()
{
var source = new string[10];
// CS0411 The type arguments cannot be inferred from usage.
var validGuids = source.TrySelect((x, out y) => Guid.TryParse(x, out y));
}
} With simple lambda parameters with modifiers should this be valid now? I saw #9453, but I think this is a separate case because this isn't dealing with complex/nested type arguments; |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
I don't believe that this behavior is by design, so this is not a language design bug. Compiler bug reports should be created at https://github.com/dotnet/roslyn/issues/new?template=bug-report.md to get the appropriate eyes on them. |
Beta Was this translation helpful? Give feedback.
-
They essentially said "not our problem" and closed it immediately, so it probably has to be submitted as a brand new language proposal. |
Beta Was this translation helpful? Give feedback.
They essentially said "not our problem" and closed it immediately, so it probably has to be submitted as a brand new language proposal.