Skip to content

Commit d4fcbb7

Browse files
authored
fix incomplete match location for some expressions (#12897)
* fix match location * fix baseline * fix
1 parent a99f8bf commit d4fcbb7

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

src/fsharp/CheckExpressions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5842,7 +5842,7 @@ and TcExprUndelayed cenv (overallTy: OverallTy) env tpenv (synExpr: SynExpr) =
58425842
let inputExpr, inputTy, tpenv =
58435843
let env = { env with eIsControlFlow = false }
58445844
TcExprOfUnknownType cenv env tpenv synInputExpr
5845-
let mInputExpr = inputExpr.Range
5845+
let mInputExpr = synInputExpr.Range
58465846
let env = { env with eIsControlFlow = true }
58475847
let matchVal, matchExpr, tpenv = TcAndPatternCompileMatchClauses mInputExpr mInputExpr ThrowIncompleteMatchException cenv (Some inputExpr) inputTy overallTy env tpenv synClauses
58485848
let overallExpr = mkLet spMatch mInputExpr matchVal inputExpr matchExpr

tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/RelaxWhitespace2.fs.err.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ RelaxWhitespace2.fs (2742,9)-(2744,13) typecheck warning Incomplete pattern matc
4141
RelaxWhitespace2.fs (3391,13)-(3391,14) typecheck warning Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).
4242
RelaxWhitespace2.fs (3394,13)-(3394,14) typecheck warning Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).
4343
RelaxWhitespace2.fs (3397,13)-(3397,14) typecheck warning Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).
44-
RelaxWhitespace2.fs (3403,21)-(3403,22) typecheck warning Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).
44+
RelaxWhitespace2.fs (3401,13)-(3406,21) typecheck warning Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).
4545
RelaxWhitespace2.fs (3410,13)-(3415,20) typecheck warning Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).
4646
RelaxWhitespace2.fs (3713,1)-(3713,9) typecheck warning Incomplete pattern matches on this expression. For example, the value '{ y=0 }' may indicate a case not covered by the pattern(s).
4747
RelaxWhitespace2.fs (3720,1)-(3720,9) typecheck warning Incomplete pattern matches on this expression.

tests/fsharp/typecheck/sigs/neg102.bsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ neg102.fs(32,14,32,22): typecheck error FS0104: Enums may take values outside kn
1616
neg102.fs(37,14,37,22): typecheck error FS0104: Enums may take values outside known cases. For example, the value 'Some (enum<EnumABC> (2))' may indicate a case not covered by the pattern(s).
1717

1818
neg102.fs(44,14,44,22): typecheck error FS0104: Enums may take values outside known cases. For example, the value 'enum<System.DateTimeKind> (3)' may indicate a case not covered by the pattern(s).
19+
20+
neg102.fs(51,15,55,10): typecheck error FS0025: Incomplete pattern matches on this expression. For example, the value 'Some (_)' may indicate a case not covered by the pattern(s).

tests/fsharp/typecheck/sigs/neg102.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ module FS0104 =
4545
| System.DateTimeKind.Unspecified -> "Unspecified"
4646
| System.DateTimeKind.Utc -> "Utc"
4747
| System.DateTimeKind.Local -> "Local"
48+
49+
module IncompleteMatchWarningAtRightPlace =
50+
let f() =
51+
match (
52+
let value = 5
53+
value + 4
54+
|> Some
55+
)
56+
with
57+
| None -> ()

tests/fsharp/typecheck/sigs/neg102.vsbsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ neg102.fs(32,14,32,22): typecheck error FS0104: Enums may take values outside kn
1616
neg102.fs(37,14,37,22): typecheck error FS0104: Enums may take values outside known cases. For example, the value 'Some (enum<EnumABC> (2))' may indicate a case not covered by the pattern(s).
1717

1818
neg102.fs(44,14,44,22): typecheck error FS0104: Enums may take values outside known cases. For example, the value 'enum<System.DateTimeKind> (3)' may indicate a case not covered by the pattern(s).
19+
20+
neg102.fs(51,15,55,10): typecheck error FS0025: Incomplete pattern matches on this expression. For example, the value 'Some (_)' may indicate a case not covered by the pattern(s).

tests/service/PatternMatchCompilationTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ match Unchecked.defaultof<int> with
457457
"""
458458
assertHasSymbolUsages ["a"] checkResults
459459
dumpErrors checkResults |> shouldEqual [
460-
"(2,6--2,25): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."
460+
"(2,6--2,30): Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s)."
461461
"(6,2--6,6): The type 'int' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion."
462462
]
463463

0 commit comments

Comments
 (0)