-
Notifications
You must be signed in to change notification settings - Fork 161
implement codefix for C# lambda => F# lambda #667
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
implement codefix for C# lambda => F# lambda #667
Conversation
70be538
to
5b7bf93
Compare
reporting of this error is much better now. I'd love to hear about more scenarios where we can detect this. |
@@ -49,6 +55,28 @@ module FCSPatches = | |||
result.IsSome | |||
| _ -> false | |||
|
|||
member scope.TryRangeOfParenEnclosingOpEqualsGreaterUsage opGreaterEqualPos = | |||
let (|InfixAppOfOpEqualsGreater|_|) = | |||
function | SynExpr.App(ExprAtomicFlag.NonAtomic, false, SynExpr.App(ExprAtomicFlag.NonAtomic, true, Ident "op_EqualsGreater", actualParamListExpr, _), actualLambdaBodyExpr, _) -> Some (actualParamListExpr, actualLambdaBodyExpr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I freaking love active patterns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so fun fact: this is the shape of this erroneous usage, so any more cases we want to cover should just be a matter of plugging this into the appropriate expr
match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without active patterns, matching the F# AST would be so much harder!
when passing a C# lambda (wrapped in parens), the compiler sees it as (roughly):
so we can extract that pattern out and rewrite it.
This handles the following cases:
someFunc (thing => otherthing)
let thing = args => body