Skip to content
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

Test plan for "static lambdas" #39606

Closed
33 of 34 tasks
jcouv opened this issue Oct 31, 2019 · 5 comments
Closed
33 of 34 tasks

Test plan for "static lambdas" #39606

jcouv opened this issue Oct 31, 2019 · 5 comments
Assignees
Labels
Area-Compilers Test Test failures in roslyn-CI Test-Gap Describes a specific feature or scenario that does not have test coverage
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Oct 31, 2019

Championed issue: dotnet/csharplang#275
Speclet: https://github.com/dotnet/csharplang/blob/master/proposals/static-lambdas.md
Main PR: #39121

Compiler scenarios

  • LangVer (DisallowInNonPreview)
  • static lambda cannot reference locals, parameters or this (StaticLambdaCannotCaptureInstanceField, StaticLambdaCannotCaptureParameter, StaticLambdaCannotReferenceBase and following)
  • static lambda can reference static fields/methods/properties (StaticLambdaCanReferenceStaticField, StaticLambdaCanCallStaticMethod and following)
  • static lambda can reference const field/local (StaticLambdaCanReferenceConstField and following)
  • static lambda inside regular lambda (InstanceLambdaCannotHaveLocalsCapturedByInnerStaticLambda,
  • regular lambda inside static lambda (still cannot capture outer locals, parameters or this) (StaticLambdaCanHaveLocalsCapturedByInnerInstanceLambda
  • similar mixing of static and regular with lambdas and local functions (StaticLambdaCannotReferenceInstanceLocalFunction, StaticLambdaCanReferenceStaticLocalFunction, StaticLambdaCannotHaveLocalsCapturedByInnerStaticLambda, StaticLambdaCanHaveLocalsCapturedByInnerInstanceLocalFunction): outer and inner, either may be lambda or local function, either may be static or instance, check referencing variables from outer and middle scope.
  • verify nameof (can still reference)
  • can reference type parameters from enclosing method (default(T)), should be same as local functions
  • verify with various lambda syntaxes (with/without types)
  • test in top-level statements, with nint,
  • success cases should be executed (produce an output), verify diagnostics and emit diagnostics
  • static delegate (including parse tree test)
  • parse tree test for all supported lambdas
  • verify accessibility of private members (instance and static)
  • capture what metadata we emit (although no guarantee, same IL as non-static lambda to avoid inefficiency)
  • static should not interfere with caching (this falls under the "should not effect emit/validity" umbrella)
  • verify that static lambda can be used in expression tree
  • verify semantic model, verify symbol API, (verify .IsStatic), verify data flow
  • verify IOperation (IAnonymousFunction, symbol covers need for API)
  • Static anonymous funcs as call arguments:
    • M(static ...)
    • M(ref static ...)
    • M(param: static ...)
    • Also indexers: obj[static ...] and variants
  • test with lambda discard parameters
  • test in ternary (with cast on one side, or with target-typing with new feature), ref ternary (error), and switch expression
  • review language parser for "is possible lambda" function
  • check diagnostic and parse tree on trying to convert a static lambda to a function pointer (review message)

Productivity

  • converting static anonymous function to static local function This refactoring does not seem to exist for regular anonymous functions.
  • make anonymous function 'static' Add "make anonymous function static" code fix #45832
  • recommend static keyword
  • verify what captures are displayed (empty set)
    • in practice we display whatever is being captured, including things which are an error to capture.

LDM

  • confirm static delegate (current implementation allows)
@jcouv jcouv added Area-Compilers Test Test failures in roslyn-CI labels Oct 31, 2019
@jcouv jcouv added this to the Compiler.Next milestone Oct 31, 2019
@jcouv jcouv self-assigned this Oct 31, 2019
@huoyaoyuan
Copy link
Member

recommend static keyword

Please take in mind for an option to not suggest static keyword.
Many short lambdas, especially in LINQ, will look very redundant with static.

@CyrusNajmabadi
Copy link
Member

@huoyaoyuan this just means: as the user is typing, the completion list should offer the static keyword to ensure that they can quickly complete to it instead of having to type the whole word out.

@huoyaoyuan
Copy link
Member

Well I misunderstood as an IDE diagnostic like static local functions.
readonly structs and struct members both became available with no keyword recommender support. I guest you were too busy for the due date.

@CyrusNajmabadi
Copy link
Member

readonly structs and struct members both became available with no keyword recommender support. I guest you were too busy for the due date.

That sounds like something was simply missed in the test plan. It's normally a requirement that new syntactic forms be supported in intellisense for a lang feature to ship.

@jcouv jcouv modified the milestones: Compiler.Next, Compiler.Net5 Dec 11, 2019
@gafter gafter added the Test-Gap Describes a specific feature or scenario that does not have test coverage label Jan 2, 2020
@jaredpar jaredpar modified the milestones: Compiler.Net5, 16.8 Jun 23, 2020
@jcouv
Copy link
Member Author

jcouv commented Jul 24, 2020

The feature was merged and open test plan follow-ups have tracking issues. I'll go ahead and close the test plan.
FYI @jaredpar

@jcouv jcouv closed this as completed Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Test Test failures in roslyn-CI Test-Gap Describes a specific feature or scenario that does not have test coverage
Projects
Status: Done Umbrellas
Development

No branches or pull requests

6 participants