diff --git a/src/FSharpLint.Core/Application/Configuration.fs b/src/FSharpLint.Core/Application/Configuration.fs index 38560bc45..122de462e 100644 --- a/src/FSharpLint.Core/Application/Configuration.fs +++ b/src/FSharpLint.Core/Application/Configuration.fs @@ -83,7 +83,7 @@ module IgnoreFiles = let isDirectory = path.EndsWith("/") let getRegexSegments (path:string) = - path.Split([| '/' |], StringSplitOptions.RemoveEmptyEntries) + path.Split(Array.singleton '/', StringSplitOptions.RemoveEmptyEntries) |> Array.map globToRegex if path.StartsWith("!") then diff --git a/src/FSharpLint.Core/Application/Lint.fs b/src/FSharpLint.Core/Application/Lint.fs index ac91adea9..cc0c75014 100644 --- a/src/FSharpLint.Core/Application/Lint.fs +++ b/src/FSharpLint.Core/Application/Lint.fs @@ -327,7 +327,7 @@ module Lint = let loader = Ionide.ProjInfo.WorkspaceLoader.Create toolsPath let notifications = ResizeArray<_>() loader.Notifications.Add notifications.Add - let options = loader.LoadProjects [projectFilePath] + let options = loader.LoadProjects (List.singleton projectFilePath) options |> Seq.tryFind (fun opt -> opt.ProjectFileName = projectFilePath) |> Option.map (fun proj -> Ionide.ProjInfo.FCS.mapToFSharpProjectOptions proj options) diff --git a/src/FSharpLint.Core/Framework/Ast.fs b/src/FSharpLint.Core/Framework/Ast.fs index 43e4e6d2b..fe02616b3 100644 --- a/src/FSharpLint.Core/Framework/Ast.fs +++ b/src/FSharpLint.Core/Framework/Ast.fs @@ -54,7 +54,7 @@ module Ast = match op.idText with | "op_PipeRight" | "op_PipeRight2" | "op_PipeRight3" -> - flattenFuncExpr [rhs] lhs + flattenFuncExpr (List.singleton rhs) lhs | "op_PipeLeft" | "op_PipeLeft2" | "op_PipeLeft3" -> flattenFuncExpr (lhs::flattened) rhs | _ -> flattenFuncExpr (lhs::flattened) app @@ -337,7 +337,7 @@ module Ast = ) andBangs add <| Pattern pattern | [] -> () // error case. @@TODO@@ any other handling needed here? - | SynExpr.Ident(ident) -> add <| Identifier([ident.idText], ident.idRange) + | SynExpr.Ident(ident) -> add <| Identifier(List.singleton ident.idText, ident.idRange) | SynExpr.LongIdent(_, SynLongIdent(ident, _, _), _, range) -> add <| Identifier(List.map (fun (identifier: Ident) -> identifier.idText) ident, range) | SynExpr.IfThenElse(cond, body, Some(elseExpr), _, _, _, _) -> @@ -404,7 +404,7 @@ module Ast = add <| Type synType add <| SimplePattern simplePattern | SynSimplePat.Attrib(simplePattern, _, _) -> add <| SimplePattern simplePattern - | SynSimplePat.Id(identifier, _, _, _, _, _) -> add <| Identifier([identifier.idText], identifier.idRange) + | SynSimplePat.Id(identifier, _, _, _, _, _) -> add <| Identifier(List.singleton identifier.idText, identifier.idRange) let inline private matchChildren node add = match node with diff --git a/src/FSharpLint.Core/Framework/HintParser.fs b/src/FSharpLint.Core/Framework/HintParser.fs index a8648f1f8..9276c4907 100644 --- a/src/FSharpLint.Core/Framework/HintParser.fs +++ b/src/FSharpLint.Core/Framework/HintParser.fs @@ -67,7 +67,7 @@ module HintParser = let private plongident: (CharStream -> Reply) = choice [ attempt (sepBy1 pident (skipChar '.')) - pident |>> fun identChars -> [identChars] ] + pident |>> List.singleton ] let private pidentorop: (CharStream -> Reply) = choice @@ -86,9 +86,9 @@ module HintParser = |>> (fun ((startIdent, idents), maybeOperator) -> let identifiers = startIdent::idents match maybeOperator with - | Some(operator) -> identifiers@[operator] + | Some(operator) -> identifiers @ (List.singleton operator) | None -> identifiers) - attempt (pidentorop |>> fun identOrOpChars -> [identOrOpChars]) + attempt (pidentorop |>> List.singleton) plongident ] |>> List.map charListToString @@ -538,7 +538,7 @@ module HintParser = let op = InfixOperator(prefix, remainingOpChars, precedence, associativity, (), fun remOpChars expr1 expr2 -> - let opIdent = Expression.Identifier [prefix + remOpChars] + let opIdent = Expression.Identifier (List.singleton (prefix + remOpChars)) Expression.InfixOperator(opIdent, expr1, expr2)) opp.AddOperator(op) @@ -555,10 +555,10 @@ module HintParser = if prefix = "&" then Expression.AddressOf(true, expr) else if prefix = "&&" then Expression.AddressOf(false, expr) else if prefix = "!" || prefix = "~" then - let opIdent = Expression.Identifier [prefix + remOpChars] + let opIdent = Expression.Identifier (List.singleton (prefix + remOpChars)) Expression.PrefixOperator(opIdent, expr) else - let opIdent = Expression.Identifier ["~" + prefix + remOpChars] + let opIdent = Expression.Identifier (List.singleton ("~" + prefix + remOpChars)) Expression.PrefixOperator(opIdent, expr) let prefixOp = diff --git a/src/FSharpLint.Core/Framework/HintParserUtilities.fs b/src/FSharpLint.Core/Framework/HintParserUtilities.fs index e4cb72f56..de6922a50 100644 --- a/src/FSharpLint.Core/Framework/HintParserUtilities.fs +++ b/src/FSharpLint.Core/Framework/HintParserUtilities.fs @@ -155,13 +155,13 @@ module MergeSyntaxTrees = | HintExpr(Expression.Lambda(args, LambdaBody(body))) -> [ for LambdaArg(arg) in args -> HintExpr arg yield HintExpr body ] - | HintExpr(Expression.LambdaArg(arg)) -> [ HintExpr arg ] - | HintExpr(Expression.LambdaBody(body)) -> [ HintExpr body ] + | HintExpr(Expression.LambdaArg(arg)) -> List.singleton (HintExpr arg) + | HintExpr(Expression.LambdaBody(body)) -> List.singleton (HintExpr body ) | HintExpr(Expression.InfixOperator(Expression.Identifier([ "::" ]) as ident, lhs, rhs)) -> [ HintExpr ident; HintExpr(Expression.Tuple([ lhs; rhs ])) ] | HintExpr(Expression.InfixOperator(ident, lhs, rhs)) -> [ HintExpr ident; HintExpr lhs; HintExpr rhs ] | HintExpr(Expression.PrefixOperator(ident, expr)) -> [ HintExpr ident; HintExpr expr ] - | HintExpr(Expression.AddressOf(_, expr)) -> [ HintExpr expr ] + | HintExpr(Expression.AddressOf(_, expr)) -> List.singleton (HintExpr expr) | HintExpr(Expression.FunctionApplication(exprs)) | HintExpr(Expression.Tuple(exprs)) | HintExpr(Expression.List(exprs)) @@ -169,7 +169,7 @@ module MergeSyntaxTrees = | HintExpr(Expression.If(ifCond, bodyExpr, Some(elseExpr))) -> [ HintExpr ifCond; HintExpr bodyExpr; HintExpr elseExpr ] | HintExpr(Expression.If(ifCond, bodyExpr, None)) -> [ HintExpr ifCond; HintExpr bodyExpr ] - | HintExpr(Expression.Else(expression)) -> [ HintExpr expression ] + | HintExpr(Expression.Else(expression)) -> List.singleton (HintExpr expression) | HintExpr(Expression.Identifier(_)) | HintExpr(Expression.Constant(_)) | HintExpr(Expression.Null) @@ -180,7 +180,7 @@ module MergeSyntaxTrees = | HintPat(Pattern.Array(patterns)) | HintPat(Pattern.List(patterns)) | HintPat(Pattern.Tuple(patterns)) -> List.map HintPat patterns - | HintPat(Pattern.Parentheses(pattern)) -> [ HintPat pattern ] + | HintPat(Pattern.Parentheses(pattern)) -> List.singleton (HintPat pattern) | HintPat(Pattern.Variable(_)) | HintPat(Pattern.Identifier(_)) | HintPat(Pattern.Constant(_)) @@ -385,7 +385,7 @@ module MergeSyntaxTrees = | _ -> failwith "Invalid state" let private getEdges transposed = - getEdgesRec [ProcessTransposed(transposed)] None + getEdgesRec (List.singleton <| ProcessTransposed transposed) None let mergeHints hints = let transposed = hints |> List.map hintToList |> transposeHead diff --git a/src/FSharpLint.Core/Framework/Utilities.fs b/src/FSharpLint.Core/Framework/Utilities.fs index 266342a49..36d46a6c4 100644 --- a/src/FSharpLint.Core/Framework/Utilities.fs +++ b/src/FSharpLint.Core/Framework/Utilities.fs @@ -48,7 +48,7 @@ module ExpressionUtilities = open FSharp.Compiler.CodeAnalysis let (|Identifier|_|) = function - | SynExpr.Ident(ident) -> Some([ident], ident.idRange) + | SynExpr.Ident(ident) -> Some(List.singleton ident, ident.idRange) | SynExpr.LongIdent(_, longIdent, _, _) -> Some(longIdent.LongIdent, longIdent.Range) | _ -> None diff --git a/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs b/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs index 8e306e481..1013b9e91 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Binding/UselessBinding.fs @@ -33,7 +33,7 @@ let private runner (args:AstNodeRuleParams) = let checkNotMutable (ident:Ident) = fun () -> let maybeSymbol = checkFileResults.GetSymbolUseAtLocation( - ident.idRange.StartLine, ident.idRange.EndColumn, String.Empty, [ident.idText]) + ident.idRange.StartLine, ident.idRange.EndColumn, String.Empty, List.singleton ident.idText) match maybeSymbol with | Some(symbol) -> isNotMutable symbol diff --git a/src/FSharpLint.Core/Rules/Conventions/FavourSingleton.fs b/src/FSharpLint.Core/Rules/Conventions/FavourSingleton.fs index 1279c2efb..04a5d7e3e 100644 --- a/src/FSharpLint.Core/Rules/Conventions/FavourSingleton.fs +++ b/src/FSharpLint.Core/Rules/Conventions/FavourSingleton.fs @@ -17,15 +17,28 @@ let runner args = SuggestedFix = None TypeChecks = List.Empty } match args.AstNode with - | AstNode.Binding(SynBinding(_, _, _, _, _, _, _, _, _, expression, _, _, _)) -> + | AstNode.Expression(expression) -> match expression with - | SynExpr.ArrayOrListComputed(_isArray, innerExpr, range) -> + | SynExpr.ArrayOrListComputed(_isArray, innerExpr, _) -> match innerExpr with - | SynExpr.Const(_, range) -> - generateViolation range - | SynExpr.Ident _ -> - generateViolation range - | _ -> Array.empty + | SynExpr.ComputationExpr _ + | SynExpr.For _ + | SynExpr.ForEach _ + | SynExpr.IfThenElse _ + | SynExpr.IndexRange _ + | SynExpr.LetOrUse _ + | SynExpr.Match _ + | SynExpr.Sequential _ + | SynExpr.SequentialOrImplicitYield _ + | SynExpr.Set _ + | SynExpr.TryFinally _ + | SynExpr.TryWith _ + | SynExpr.While _ + | SynExpr.YieldOrReturn _ + | SynExpr.YieldOrReturnFrom _ -> + Array.empty + | _ -> + generateViolation expression.Range | _ -> Array.empty | _ -> Array.empty let rule = diff --git a/src/FSharpLint.Core/Rules/Conventions/Naming/AvoidTooShortNames.fs b/src/FSharpLint.Core/Rules/Conventions/Naming/AvoidTooShortNames.fs index 8c904a448..4b2662eb9 100644 --- a/src/FSharpLint.Core/Rules/Conventions/Naming/AvoidTooShortNames.fs +++ b/src/FSharpLint.Core/Rules/Conventions/Naming/AvoidTooShortNames.fs @@ -61,7 +61,7 @@ let runner (args:AstNodeRuleParams) = | AstNode.Expression(ExpressionUtilities.LetOrUse({Bindings = binding :: _}, true, _)) -> match binding with | SynBinding(headPat = pat) -> - getParameterWithBelowMinimumLength [pat] + getParameterWithBelowMinimumLength (List.singleton pat) | AstNode.Expression(SynExpr.Lambda(_, _, lambdaArgs, _, _, _, _)) -> let lambdaIdent = FunctionReimplementation.getLambdaParamIdent lambdaArgs match lambdaIdent with @@ -72,7 +72,7 @@ let runner (args:AstNodeRuleParams) = | AstNode.Expression(SynExpr.For(_, _, identifier, _, _, _, _, _, _)) when isIdentifierTooShort identifier.idText -> Array.singleton (identifier, identifier.idText, None) | AstNode.Match(SynMatchClause(namePattern, _, _, _, _, _)) -> - getParameterWithBelowMinimumLength [namePattern] + getParameterWithBelowMinimumLength (List.singleton namePattern) | AstNode.Binding(SynBinding(_, _, _, _, _, _, _, pattern, _, _, _, _, _)) -> match pattern with | SynPat.LongIdent(SynLongIdent(idents, _, _),_, _, SynArgPats.Pats(names), _, _) -> diff --git a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs index 3a272ff6a..499dd663c 100644 --- a/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs +++ b/src/FSharpLint.Core/Rules/Hints/HintMatcher.fs @@ -144,7 +144,7 @@ module private MatchExpression = let private matchExpr = function | AstNode.Expression(ExpressionUtilities.Identifier([ident], _)) -> let ident = identAsDecompiledOpName ident - Some(Expression.Identifier([ident])) + Some(Expression.Identifier(List.singleton ident)) | AstNode.Expression(SynExpr.LongIdent(_, ident, _, _)) -> let identifier = List.map (fun (ident: Ident) -> ident.idText) ident.LongIdent Some(Expression.Identifier(identifier)) @@ -192,7 +192,7 @@ module private MatchExpression = | Some checkFile -> let maybeSymbolUse = checkFile.GetSymbolUseAtLocation( - ident.idRange.StartLine, ident.idRange.EndColumn, String.Empty, [ident.idText]) + ident.idRange.StartLine, ident.idRange.EndColumn, String.Empty, List.singleton ident.idText) match maybeSymbolUse with | Some symbolUse -> @@ -420,7 +420,7 @@ module private MatchExpression = Expression.PrefixOperator(Expression.Identifier([op]), expr)) -> matchHintExpr (fun () -> arguments.SubHint(AstNode.Expression(rightExpr), expr) |> matchHintExpr returnEmptyMatch) - (arguments.SubHint(AstNode.Expression(opExpr), Expression.Identifier([op]))) + (arguments.SubHint(AstNode.Expression(opExpr), Expression.Identifier(List.singleton op))) | _ -> NoMatch and [] private matchAddressOf arguments = diff --git a/src/FSharpLint.Core/Rules/NamingHelper.fs b/src/FSharpLint.Core/Rules/NamingHelper.fs index 562b7ae39..0c60915fc 100644 --- a/src/FSharpLint.Core/Rules/NamingHelper.fs +++ b/src/FSharpLint.Core/Rules/NamingHelper.fs @@ -324,7 +324,7 @@ let isMeasureType = isAttribute "Measure" let isNotUnionCase (checkFile:FSharpCheckFileResults) (ident:Ident) = let maybeSymbol = checkFile.GetSymbolUseAtLocation( - ident.idRange.StartLine, ident.idRange.EndColumn, String.Empty, [ident.idText]) + ident.idRange.StartLine, ident.idRange.EndColumn, String.Empty, List.singleton ident.idText) match maybeSymbol with | Some(symbol) when (symbol.Symbol :? FSharpUnionCase) -> false diff --git a/tests/FSharpLint.Console.Tests/TestApp.fs b/tests/FSharpLint.Console.Tests/TestApp.fs index 22d4e8bd0..3cb88e174 100644 --- a/tests/FSharpLint.Console.Tests/TestApp.fs +++ b/tests/FSharpLint.Console.Tests/TestApp.fs @@ -6,7 +6,7 @@ open NUnit.Framework open FSharpLint.Console.Program let getErrorsFromOutput (output:string) = - let splitOutput = output.Split([|Environment.NewLine|], StringSplitOptions.None) + let splitOutput = output.Split(Array.singleton Environment.NewLine, StringSplitOptions.None) set [ for index in 1..splitOutput.Length - 1 do if splitOutput.[index].StartsWith "Error" then yield splitOutput.[index - 1] ] @@ -46,7 +46,7 @@ type TestConsoleApplication() = let (returnCode, errors) = main [| "lint"; input.FileName |] Assert.AreEqual(int ExitCode.Failure, returnCode) - Assert.AreEqual(set ["Consider changing `Signature` to be prefixed with `I`."], errors) + Assert.AreEqual(Set.singleton "Consider changing `Signature` to be prefixed with `I`.", errors) [] member _.``Lint source without any config, rule enabled in default config is triggered for given source.``() = @@ -59,7 +59,7 @@ type TestConsoleApplication() = let (returnCode, errors) = main [| "lint"; input |] Assert.AreEqual(int ExitCode.Failure, returnCode) - Assert.AreEqual(set ["Consider changing `Signature` to be prefixed with `I`."], errors) + Assert.AreEqual(Set.singleton "Consider changing `Signature` to be prefixed with `I`.", errors) [] member _.``Lint source with valid config to disable rule, disabled rule is not triggered for given source.``() = @@ -117,7 +117,7 @@ type TestConsoleApplication() = let (returnCode, errors) = main [| "lint"; "--lint-config"; config.FileName; input |] Assert.AreEqual(int ExitCode.Failure, returnCode) - Assert.AreEqual(set ["Use prefix syntax for generic type."], errors) + Assert.AreEqual(Set.singleton "Use prefix syntax for generic type.", errors) [] type TestFileTypeInference() = diff --git a/tests/FSharpLint.Core.Tests/Framework/TestConfiguration.fs b/tests/FSharpLint.Core.Tests/Framework/TestConfiguration.fs index aa7d97ec7..08424c765 100644 --- a/tests/FSharpLint.Core.Tests/Framework/TestConfiguration.fs +++ b/tests/FSharpLint.Core.Tests/Framework/TestConfiguration.fs @@ -15,7 +15,7 @@ let configWithHints hints = type TestConfiguration() = [] member _.``Ignore all files ignores any given file.``() = - let ignorePaths = [ IgnoreFiles.parseIgnorePath "*" ] + let ignorePaths = List.singleton (IgnoreFiles.parseIgnorePath "*") let path = @"D:\dog\source.fs".ToPlatformIndependentPath() @@ -24,7 +24,7 @@ type TestConfiguration() = [] member _.``Ignoring a file name not inside a path does not ignore the path``() = - let ignorePaths = [ IgnoreFiles.parseIgnorePath "cat" ] + let ignorePaths = List.singleton (IgnoreFiles.parseIgnorePath "cat") let path = @"D:\dog\source.fs".ToPlatformIndependentPath() @@ -33,7 +33,7 @@ type TestConfiguration() = [] member _.``Ignoring a file doesn't ignore a directory.``() = - let ignorePaths = [ IgnoreFiles.parseIgnorePath "dog" ] + let ignorePaths = List.singleton (IgnoreFiles.parseIgnorePath "dog") let path = @"D:\dog\source.fs".ToPlatformIndependentPath() @@ -42,7 +42,7 @@ type TestConfiguration() = [] member _.``Ignoring a directory doesn't ignore a file.``() = - let ignorePaths = [ IgnoreFiles.parseIgnorePath "source.fs/" ] + let ignorePaths = List.singleton (IgnoreFiles.parseIgnorePath "source.fs/") let path = @"D:\dog\source.fs".ToPlatformIndependentPath() @@ -51,7 +51,7 @@ type TestConfiguration() = [] member _.``Ignoring all files in a given directory ignores a given file from the directory.``() = - let ignorePaths = [ IgnoreFiles.parseIgnorePath "dog/*" ] + let ignorePaths = List.singleton (IgnoreFiles.parseIgnorePath "dog/*") let path = @"D:\dog\source.fs".ToPlatformIndependentPath() @@ -60,7 +60,7 @@ type TestConfiguration() = [] member _.``Ignoring a file that does not exist inside a directory that does exist does not ignore the file.``() = - let ignorePaths = [ IgnoreFiles.parseIgnorePath "dog/source1" ] + let ignorePaths = List.singleton (IgnoreFiles.parseIgnorePath "dog/source1") let path = @"D:\dog\source.fs".ToPlatformIndependentPath() diff --git a/tests/FSharpLint.Core.Tests/Framework/TestFuzzyHintMatcher.fs b/tests/FSharpLint.Core.Tests/Framework/TestFuzzyHintMatcher.fs index 4df089bda..7ee292f09 100644 --- a/tests/FSharpLint.Core.Tests/Framework/TestFuzzyHintMatcher.fs +++ b/tests/FSharpLint.Core.Tests/Framework/TestFuzzyHintMatcher.fs @@ -161,7 +161,7 @@ do let array = generateAst source |> astToArray - let hintTrie = MergeSyntaxTrees.mergeHints [toHint @"fun _ -> () ===> ignore"] + let hintTrie = MergeSyntaxTrees.mergeHints (List.singleton (toHint @"fun _ -> () ===> ignore")) let matches = ResizeArray() @@ -179,7 +179,7 @@ do let array = generateAst source |> astToArray - let hintTrie = MergeSyntaxTrees.mergeHints [toHint @"List.isEmpty [] ===> true"] + let hintTrie = MergeSyntaxTrees.mergeHints (List.singleton (toHint @"List.isEmpty [] ===> true")) let matches = ResizeArray() @@ -197,7 +197,7 @@ do let array = generateAst source |> astToArray - let hintTrie = MergeSyntaxTrees.mergeHints [toHint @"x + 0 ===> x"] + let hintTrie = MergeSyntaxTrees.mergeHints (List.singleton (toHint @"x + 0 ===> x")) let matches = ResizeArray() @@ -215,7 +215,7 @@ do let array = generateAst source |> astToArray - let hintTrie = MergeSyntaxTrees.mergeHints [toHint @"~~~1 ===> x"] + let hintTrie = MergeSyntaxTrees.mergeHints (List.singleton (toHint @"~~~1 ===> x")) let matches = ResizeArray() @@ -234,8 +234,7 @@ do let array = generateAst source |> astToArray - let hintTrie = MergeSyntaxTrees.mergeHints [toHint @"List.rev (List.rev x) ===> x"] - + let hintTrie = MergeSyntaxTrees.mergeHints (List.singleton (toHint @"List.rev (List.rev x) ===> x")) let matches = ResizeArray() possibleMatches array hintTrie (fun n1 hint -> matches.Add(n1, hint)) @@ -252,7 +251,7 @@ do let array = generateAst source |> astToArray - let hintTrie = MergeSyntaxTrees.mergeHints [toHint @"fun x -> x ===> id"] + let hintTrie = MergeSyntaxTrees.mergeHints (List.singleton (toHint @"fun x -> x ===> id")) let matches = ResizeArray() @@ -270,7 +269,7 @@ do let array = generateAst source |> astToArray - let hintTrie = MergeSyntaxTrees.mergeHints [toHint @"fun x -> x ===> id"] + let hintTrie = MergeSyntaxTrees.mergeHints (List.singleton (toHint @"fun x -> x ===> id")) let matches = ResizeArray() diff --git a/tests/FSharpLint.Core.Tests/Rules/Conventions/FavourSingleton.fs b/tests/FSharpLint.Core.Tests/Rules/Conventions/FavourSingleton.fs index 3b4a9be85..8d69df8e1 100644 --- a/tests/FSharpLint.Core.Tests/Rules/Conventions/FavourSingleton.fs +++ b/tests/FSharpLint.Core.Tests/Rules/Conventions/FavourSingleton.fs @@ -22,7 +22,7 @@ let foo = [ 10; 20 ]""" let foo = [ 10 ]""" Assert.IsTrue this.ErrorsExist - Assert.IsTrue(this.ErrorExistsAt(2, 12)) + Assert.IsTrue(this.ErrorExistsAt(2, 10)) [] member this.ListWithASingleIdentShouldProduceError() = @@ -54,7 +54,7 @@ let foo = [| 10; 20 |]""" let foo = [| 10 |]""" Assert.IsTrue this.ErrorsExist - Assert.IsTrue(this.ErrorExistsAt(2, 13)) + Assert.IsTrue(this.ErrorExistsAt(2, 10)) [] member this.ArrayWithASingleIdentShouldProduceError() = @@ -73,6 +73,30 @@ let foo = [| bar; false; true |]""" this.AssertNoWarnings() + [] + member this.``List with a single item in function call should produce an error``() = + this.Parse """ +let bar lst = List.length lst +let foo = bar [ 0 ]""" + + Assert.IsTrue this.ErrorsExist + Assert.IsTrue(this.ErrorExistsAt(3, 14)) + + [] + member this.``List with a single item (that is not constant or identifier) should produce an error``() = + this.Parse """ +let foo = bar [ "baz".Length ]""" + + Assert.IsTrue this.ErrorsExist + Assert.IsTrue(this.ErrorExistsAt(2, 14)) + + [] + member this.``List expression should not produce ans error``() = + this.Parse """ +let foo = bar [ for i=0 to 3 do yield i+1 ]""" + + this.AssertNoWarnings() + [] member this.SingletonListWithMatchCaseShouldNotProduceError() = this.Parse """