-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage
Milestone
Description
- Specification checked in to
csharplang(PR Create speclet for lambda discard parameters csharplang#2901) -
(_, _) => 0with LangVersion 8 (error) (seeDiscardParameters_CSharp8) -
(_, _) => 0with LangVersion Preview (ok) (seeDiscardParameters) - also works with explicit types
(int _, string _) => 0(seeDiscardParameters_WithTypes) - also works in delegate syntax
delegate(int _, string _) { return 0; }(seeDiscardParameters_InDelegates) - discard parameters in delegates do not allow attributes (see
DiscardParameters_InDelegates_WithAttribute) - discard parameters are not in scope and cannot be read from or written to (see
DiscardParameters_NotInScope) - that a single
_is not a discard parameter (ie. is in scope and can be read from) (seeDiscardParameters_NotADiscardWhenSingleUnderscore) - Verify semantic model on discard parameters (see
DiscardParameters_NotInScope)- parameter symbol has
IsDiscardset totrue - parameter symbol has
_as name - parameter symbol has expected type and nullability
- parameter symbol has
- variable named
_allowed inside a lambda with discard parameters (seeDiscardParameters) - discard parameters with
ref,inandoutparameters (see open question below) (seeDiscardParameters_RefAndOut) - multiple
_parameters on local function (still error) (seeDiscardParameters_OnLocalFunction) - unicode underscore
\u005fdoesn't cound as discard (same as in other contexts) (seeDiscardParameters_UnicodeUnderscore) -
@_is not a discard (same as in other contexts) (seeDiscardParameters_EscapedUnderscore) - test lambda in expression tree (disallow) (see
DiscardParameters_ExpressionTreeNotAllowed) - test no regression on shadowing of underscore (see Implement lambda discard parameters #38786 (comment))
Questions raised on team review today:
- confirm desired debugging and EE behavior. Are the values visible? F# doesn't show discards while debugging, but we should try if we can. (
debugger-discardsbranch, issue Display discard values when debugging #48408) - LDM: confirm whether we want the discards to be in scope or block visibility in some way or disallow locals named
_within a scope where discard parameters exist. Some scenarios:int _ = 1; Func<int, int, int> x = (_, _) => _++; /* this currently binding to the local declared outside the lambda? */Func<int, int, int> x = (_, _) => { int _ = 1; return _; } /* this is currently allowed */
- test
nameof(_)(seeDiscardParameters_NotInScope_Nameof) -
verify(latest implementation removed the new parameter symbol)GetAttributes()if we have a new symbol - allow expression trees unless good reason not to (see
DiscardParameters) - test IDE rename
- test
GetDeclaredSymbol(seeDiscardParameters_NotInScope) - test FindAllRefs
- LDM: should we extend the feature to local functions? (see lambda-to-local-function refactoring)
Productivity
- converting from lambda with discards to local function (currently produces code with invalid parameters)
- no IDE diagnostic reporting that discard parameters are unused
- QuickInfo shows lambda parameter discards as
(discard) int _ - IDE doesn't use a special classification for discards (same as in other contexts)
- test rename (see
RenameLambdaDiscard)
Open issues for LDM:
- Should we produce a distinct error for
outorrefdiscard?
Reactions are currently unavailable
Metadata
Metadata
Labels
Area-CompilersTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage
Type
Projects
Status
Done Umbrellas