Skip to content

Commit ec0293a

Browse files
committed
Merge pull request #308 from vasily-kirichenko/return-fsharpuse-for-single-case-union-type
fixed: no FSharpSymbolUse for single case union type
2 parents a653791 + 762cd03 commit ec0293a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/fsharp/tc.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13961,6 +13961,7 @@ module EstablishTypeDefinitionCores = begin
1396113961
noAllowNullLiteralAttributeCheck()
1396213962
TcRecdUnionAndEnumDeclarations.CheckUnionCaseName cenv unionCaseName.idText unionCaseName.idRange
1396313963
let unionCase = NewUnionCase unionCaseName unionCaseName.idText [] thisTy [] XmlDoc.Empty tycon.Accessibility
13964+
writeFakeUnionCtorsToSink [ unionCase ]
1396413965
MakeUnionRepr [ unionCase ], None, NoSafeInitInfo
1396513966

1396613967
| SynTypeDefnSimpleRepr.TypeAbbrev(ParserDetail.ThereWereSignificantParseErrorsSoDoNotTypecheckThisNode, _rhsType,_) ->

tests/service/EditorTests.fs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,4 +462,21 @@ let _ = sprintf "ABCDE"
462462
typeCheckResults.GetFormatSpecifierLocations()
463463
|> Array.map (fun range -> range.StartLine, range.StartColumn, range.EndLine, range.EndColumn)
464464
|> shouldEqual [||]
465+
466+
[<Test>]
467+
let ``Single case discreminated union type definition`` () =
468+
let input =
469+
"""
470+
type DU = Case1
471+
"""
472+
473+
let file = "/home/user/Test.fsx"
474+
let untyped, typeCheckResults = parseAndTypeCheckFileInProject(file, input)
475+
typeCheckResults.GetAllUsesOfAllSymbolsInFile()
476+
|> Async.RunSynchronously
477+
|> Array.map (fun su ->
478+
let r = su.RangeAlternate
479+
r.StartLine, r.StartColumn, r.EndLine, r.EndColumn)
480+
|> shouldEqual [|(2, 10, 2, 15); (2, 5, 2, 7); (1, 0, 1, 0)|]
481+
465482

0 commit comments

Comments
 (0)