Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/fsharp/language-reference/compiler-messages/fs0067.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
description: "Learn more about: FS0067: This type test or downcast will always hold"
title: "Compiler error FS0067"
ms.date: 9/10/2025
f1_keywords:
- "FS0067"
helpviewer_keywords:
- "FS0067"
---

# FS0067: This type test or downcast will always hold

This message is given when attempting to perform a type test ([:?](../match-expressions.md)) or downcast ([:?>](../casting-and-conversions.md#downcasting)) that will always succeed based on the types involved, making the operation unnecessary.

Redundant Type test:

[!code-fsharp[FS0067-redundant-type-test](~/samples/snippets/fsharp/compiler-messages/fs0067.fsx#L2-L8)]

Redundant Downcast:

[!code-fsharp[FS0067-redundant-downcast](~/samples/snippets/fsharp/compiler-messages/fs0067.fsx#L11-L18)]

The two examples above cause the compiler to display the following message:

```text
FS0067: This type test or downcast will always hold
```

The use of `:?` and `:?>` operators is preferable when working with:

- Base classes when the runtime type might differ.
- Values of type `obj` or interfaces types.
2 changes: 2 additions & 0 deletions docs/fsharp/language-reference/compiler-messages/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
href: ./fs0037.md
- name: FS0052 - Defensive copy
href: ./fs0052.md
- name: FS0067 - This type test or downcast will always hold
href: ./fs0067.md
- name: FS0703 - Expected type parameter, not unit-of-measure parameter
href: ./fs0703.md
18 changes: 18 additions & 0 deletions samples/snippets/fsharp/compiler-messages/fs0067.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(* Redundant Type test *)
type Dog() =
member this.Bark() = printfn "Woof!"

let dog = Dog()

if dog :? Dog then
dog.Bark()

(* Redundant Downcast *)
type Cat(name: string) =
member this.Name = name

let cat = Cat("Kitten")

let sameCat = cat :?> Cat

printfn "It's still a %s" sameCat.Name