Skip to content

Commit

Permalink
Merge pull request #238 from fsprojects/issue-237
Browse files Browse the repository at this point in the history
Don't suggest eta reduction if lambda arg is part of a tuple
  • Loading branch information
Matt authored Aug 20, 2017
2 parents 72fd535 + eef1b29 commit 469dc78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FSharpLint.Core/Rules/FunctionReimplementation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module FunctionReimplementation =
simplePatternsLength simplePatterns

let rec private getLambdaParamIdent = function
| SynSimplePats.SimplePats(pattern::_, _) ->
| SynSimplePats.SimplePats([pattern], _) ->
let rec getIdent = function
| SynSimplePat.Id(ident, _, _, _, _, _) -> ident
| SynSimplePat.Typed(simplePattern, _, _)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ let f = fun a b -> a * b

this.ErrorMsg.Contains "`( * )`" |> Assert.IsTrue

/// Regression test for https://github.com/fsprojects/FSharpLint/issues/237
[<Test>]
member this.``When there's a tuple pattern in the lambda eta contraction should not be recommended.``() =
this.Parse """
module Program
let f = List.map (fun (x,_) -> id x) []
"""

this.AssertNoWarnings()

[<Test>]
member this.``Quickfix for lambda reimplementing operator is to replace the lambda with the operator.``() =
let source = """
Expand Down

0 comments on commit 469dc78

Please sign in to comment.