Skip to content

Commit d415ef9

Browse files
Don't check the unfinished expression before dot as the whole expression (#14801)
Co-authored-by: Kevin Ransom (msft) <[email protected]>
1 parent 546c046 commit d415ef9

File tree

2 files changed

+62
-5
lines changed

2 files changed

+62
-5
lines changed

src/Compiler/Checking/CheckExpressions.fs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5190,6 +5190,12 @@ and TcExprThen (cenv: cenv) overallTy env tpenv isArg synExpr delayed =
51905190

51915191
match synExpr with
51925192

5193+
// A.
5194+
// A.B.
5195+
| SynExpr.DiscardAfterMissingQualificationAfterDot (expr1, _, m) ->
5196+
let _, _, tpenv = suppressErrorReporting (fun () -> TcExprOfUnknownTypeThen cenv env tpenv expr1 [DelayedDot])
5197+
mkDefault(m, overallTy.Commit), tpenv
5198+
51935199
// A
51945200
// A.B.C
51955201
| LongOrSingleIdent (isOpt, longId, altNameRefCellOpt, mLongId) ->
@@ -5457,7 +5463,8 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE
54575463
| SynExpr.LongIdent _
54585464
| SynExpr.App _
54595465
| SynExpr.Dynamic _
5460-
| SynExpr.DotGet _ ->
5466+
| SynExpr.DotGet _
5467+
| SynExpr.DiscardAfterMissingQualificationAfterDot _ ->
54615468
error(Error(FSComp.SR.tcExprUndelayed(), synExpr.Range))
54625469

54635470
| SynExpr.Const (SynConst.String (s, _, m), _) ->
@@ -5602,10 +5609,6 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE
56025609
//SolveTypeAsError cenv env.DisplayEnv m overallTy
56035610
mkDefault(m, overallTy.Commit), tpenv
56045611

5605-
| SynExpr.DiscardAfterMissingQualificationAfterDot (expr1, _, m) ->
5606-
let _, _, tpenv = suppressErrorReporting (fun () -> TcExprOfUnknownTypeThen cenv env tpenv expr1 [DelayedDot])
5607-
mkDefault(m, overallTy.Commit), tpenv
5608-
56095612
| SynExpr.FromParseError (expr1, m) ->
56105613
//SolveTypeAsError cenv env.DisplayEnv m overallTy
56115614
let _, tpenv = suppressErrorReporting (fun () -> TcExpr cenv overallTy env tpenv expr1)

tests/service/Symbols.fs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,57 @@ let tester2: int Group = []
373373
|> shouldEqual $"int array{rank}d"
374374

375375
| other -> Assert.Fail(sprintf "myArr was supposed to be a value, but is %A" other)
376+
377+
[<Test>]
378+
let ``Unfinished long ident type `` () =
379+
let _, checkResults = getParseAndCheckResults """
380+
let g (s: string) = ()
381+
382+
let f1 a1 a2 a3 a4 =
383+
if true then
384+
a1
385+
a2
386+
387+
a3
388+
a4
389+
390+
g a2
391+
g a4
392+
393+
let f2 b1 b2 b3 b4 b5 =
394+
if true then
395+
b1.
396+
b2.
397+
b5.
398+
399+
b3.
400+
b4.
401+
402+
g b2
403+
g b4
404+
g b5.
405+
"""
406+
let symbolTypes =
407+
["a1", Some "unit"
408+
"a2", Some "unit"
409+
"a3", Some "unit"
410+
"a4", Some "unit"
411+
412+
"b1", None
413+
"b2", Some "string"
414+
"b3", None
415+
"b4", Some "string"
416+
"b5", None]
417+
|> dict
418+
419+
for symbol in getSymbolUses checkResults |> getSymbols do
420+
match symbol with
421+
| :? FSharpMemberOrFunctionOrValue as mfv ->
422+
match symbolTypes.TryGetValue(mfv.DisplayName) with
423+
| true, Some expectedType ->
424+
mfv.FullType.TypeDefinition.DisplayName |> should equal expectedType
425+
| true, None ->
426+
mfv.FullType.IsGenericParameter |> should equal true
427+
mfv.FullType.AllInterfaces.Count |> should equal 0
428+
| _ -> ()
429+
| _ -> ()

0 commit comments

Comments
 (0)