FSharpLint icon indicating copy to clipboard operation
FSharpLint copied to clipboard

Exception thrown when linting file/project through CLI tool

Open Kelvin4702 opened this issue 6 years ago • 0 comments

Description

The following source causes the cli tool to throw an exception when linting the .fs file or the .fsproj that contains the file. let first,second = fst e,snd e

Exception thrown: dotnet fsharplint -f foo.fsproj dotnet fsharplint -sf file1.fs Succeeds: dotnet fsharplint -source "let first,second = fst e,snd e"

I have not tried the same programatically through FSharpLint.Core.

Repro steps

  1. Create a file with the following source code: let first,second = fst e,snd e.
  2. Run the CLI tool on the file or the fsproj containing the file.

Expected behavior

No exception is thrown.

Actual behavior

An exception is thrown:

An item with the same key has already been added. Key: x
Exception Stack Trace:
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at FSharpLint.Rules.HintMatcher.MatchExpression.matchHintExpr(Arguments arguments) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintMatcher.fs:line 253
   at Microsoft.FSharp.Primitives.Basics.List.map2ToFreshConsTail[a,b,c](FSharpList`1 cons, FSharpFunc`3 f, FSharpList`1 xs1, FSharpList`1 xs2)
   at Microsoft.FSharp.Primitives.Basics.List.map2[T1,T2,TResult](FSharpFunc`2 mapping, FSharpList`1 xs1, FSharpList`1 xs2)
   at FSharpLint.Rules.HintMatcher.MatchExpression.doExpressionsMatch(FSharpList`1 expressions, FSharpList`1 hintExpressions, Arguments arguments) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintMatcher.fs:line 297
   at Microsoft.FSharp.Primitives.Basics.List.map2ToFreshConsTail[a,b,c](FSharpList`1 cons, FSharpFunc`3 f, FSharpList`1 xs1, FSharpList`1 xs2)
   at Microsoft.FSharp.Primitives.Basics.List.map2[T1,T2,TResult](FSharpFunc`2 mapping, FSharpList`1 xs1, FSharpList`1 xs2)
   at FSharpLint.Rules.HintMatcher.MatchExpression.doExpressionsMatch(FSharpList`1 expressions, FSharpList`1 hintExpressions, Arguments arguments) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintMatcher.fs:line 297
   at FSharpLint.Rules.HintMatcher.MatchExpression.matchHintExpr(Arguments arguments) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintMatcher.fs:line 266
   at FSharpLint.Rules.HintMatcher.confirmFuzzyMatch$cont@645(AstNodeRuleParams args, Hint hint, FSharpList`1 breadcrumbs, AstNode matchValue_0, HintNode matchValue_1, Unit unitVar) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintMatcher.fs:line 660
   at [email protected](Hint hint) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintMatcher.fs:line 686
   at FSharpLint.Rules.Helper.Hints.checkTrie(Int32 i, Node trie, Node[] nodeArray, Skip[] skipArray, Dictionary`2 boundVariables, FSharpFunc`2 notify) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintsHelper.fs:line 43
   at [email protected](Tuple`2 tupledArg) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintsHelper.fs:line 62
   at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list)
   at FSharpLint.Rules.Helper.Hints.checkTrie(Int32 i, Node trie, Node[] nodeArray, Skip[] skipArray, Dictionary`2 boundVariables, FSharpFunc`2 notify) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintsHelper.fs:line 57
   at FSharpLint.Rules.Helper.Hints.checkTrie(Int32 i, Node trie, Node[] nodeArray, Skip[] skipArray, Dictionary`2 boundVariables, FSharpFunc`2 notify) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintsHelper.fs:line 57
   at [email protected](Tuple`2 tupledArg) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintsHelper.fs:line 65
   at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list)
   at FSharpLint.Rules.Helper.Hints.checkTrie(Int32 i, Node trie, Node[] nodeArray, Skip[] skipArray, Dictionary`2 boundVariables, FSharpFunc`2 notify) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintsHelper.fs:line 57
   at FSharpLint.Rules.Helper.Hints.checkTrie(Int32 i, Node trie, Node[] nodeArray, Skip[] skipArray, Dictionary`2 boundVariables, FSharpFunc`2 notify) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintsHelper.fs:line 57
   at FSharpLint.Rules.HintMatcher.runner(Config config, AstNodeRuleParams args) in C:\projects\fsharplint-231\src\FSharpLint.Core\Rules\Hints\HintMatcher.fs:line 686
   at [email protected](RuleMetadata`1 rule) in C:\projects\fsharplint-231\src\FSharpLint.Core\Application\Lint.fs:line 240
   at Microsoft.FSharp.Collections.ArrayModule.Collect[T,TResult](FSharpFunc`2 mapping, T[] array)
   at Microsoft.FSharp.Collections.ArrayModule.Collect[T,TResult](FSharpFunc`2 mapping, T[] array)
   at FSharpLint.Application.Lint.runAstNodeRules(RuleMetadata`1[] rules, FSharpOption`1 typeCheckResults, String fileContent, Node[] syntaxArray, Skip[] skipArray) in C:\projects\fsharplint-231\src\FSharpLint.Core\Application\Lint.fs:line 217
   at FSharpLint.Application.Lint.lint(LintInfo lintInfo, FileParseInfo fileInfo) in C:\projects\fsharplint-231\src\FSharpLint.Core\Application\Lint.fs:line 315

Known workarounds

Replace the affected source with a pattern match: let first,second = fst e,snd e becomes let first,second = e

Related information

  • Operating system: Windows 10 Pro
  • dotnet-fsharplint version: 0.11.1
  • .NET Core version: 2.1.505

Kelvin4702 avatar May 23 '19 15:05 Kelvin4702