Another cause for CS1677 (and CS1661) #43779
Labels
doc-enhancement
Improve the current content [org][type][category]
dotnet-csharp/svc
errors-warnings/subsvc
Pri2
Type of issue
Missing information
Description
I'm working on the Ecma C# spec with lambda/anonymous function parameters [where I'm adding
scoped
], and my tests generated two CS errors, CS1677 and CS1661, from the same code. While I'll document the issue here, it likely will require tweaking the description for CS1661 as well.Basically, the explanation and example you currently provide does not handle my situation.
Consider the following:
The CS1677 message I get is
The CS1661 message I get is
It appears that the explicit declaration type of
lam3a
is the problem, yet I don't see any way to change that (you can't includein
in the type parameter), but when I let the compiler figure out the delegate type by usingvar
, it works. This suggests thatvar
can allow code that cannot be expressed directly using explicit types.It seems there are multiple scenarios that can result in CS1661, as the message I got in the test above does not match the one in your Help entry, which states,
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs1677?f1url=%3FappId%3Droslyn%26k%3Dk(CS1677)
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/misc/cs1677.md
Document Version Independent Id
9f888ae8-1183-8c38-f6d2-0dc075026016
Article author
@BillWagner
Metadata
Related Issues
The text was updated successfully, but these errors were encountered: