From 3f97dc06709a8d2aefd72271e08cee67af58d409 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Fri, 27 Feb 2015 13:11:14 +0300 Subject: [PATCH 1/2] fixed: no FSharpSymbolUse for single case union type https://github.com/fsharp/FSharp.Compiler.Service/issues/301 --- src/fsharp/tc.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsharp/tc.fs b/src/fsharp/tc.fs index 515f2f96e7..8129a4d2b3 100755 --- a/src/fsharp/tc.fs +++ b/src/fsharp/tc.fs @@ -13961,6 +13961,7 @@ module EstablishTypeDefinitionCores = begin noAllowNullLiteralAttributeCheck() TcRecdUnionAndEnumDeclarations.CheckUnionCaseName cenv unionCaseName.idText unionCaseName.idRange let unionCase = NewUnionCase unionCaseName unionCaseName.idText [] thisTy [] XmlDoc.Empty tycon.Accessibility + writeFakeUnionCtorsToSink [ unionCase ] MakeUnionRepr [ unionCase ], None, NoSafeInitInfo | SynTypeDefnSimpleRepr.TypeAbbrev(ParserDetail.ThereWereSignificantParseErrorsSoDoNotTypecheckThisNode, _rhsType,_) -> From 762cd033e8f50b8a4d20f13f613fc0e8da11f924 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Sat, 28 Feb 2015 16:30:06 +0300 Subject: [PATCH 2/2] add a test for GetAllUsesOfAllSymbolsInFile for single case discriminated union --- tests/service/EditorTests.fs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 2afd4c53c0..917300e010 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -462,4 +462,21 @@ let _ = sprintf "ABCDE" typeCheckResults.GetFormatSpecifierLocations() |> Array.map (fun range -> range.StartLine, range.StartColumn, range.EndLine, range.EndColumn) |> shouldEqual [||] + +[] +let ``Single case discreminated union type definition`` () = + let input = + """ +type DU = Case1 +""" + + let file = "/home/user/Test.fsx" + let untyped, typeCheckResults = parseAndTypeCheckFileInProject(file, input) + typeCheckResults.GetAllUsesOfAllSymbolsInFile() + |> Async.RunSynchronously + |> Array.map (fun su -> + let r = su.RangeAlternate + r.StartLine, r.StartColumn, r.EndLine, r.EndColumn) + |> shouldEqual [|(2, 10, 2, 15); (2, 5, 2, 7); (1, 0, 1, 0)|] + \ No newline at end of file