Skip to content

Commit 10dd246

Browse files
64J0BillWagner
andauthored
[F#] Add FS0410 compiler message (dotnet#49100)
* Add FS0410 compiler message * Fix ms.date * Fix text * Update docs/fsharp/language-reference/compiler-messages/fs0410.md Co-authored-by: Bill Wagner <[email protected]> * Update docs/fsharp/language-reference/compiler-messages/fs0410.md Co-authored-by: Bill Wagner <[email protected]> * Update docs/fsharp/language-reference/compiler-messages/fs0410.md Co-authored-by: Bill Wagner <[email protected]> * Update docs/fsharp/language-reference/compiler-messages/toc.yml Co-authored-by: Bill Wagner <[email protected]> * Update docs/fsharp/language-reference/compiler-messages/fs0410.md Co-authored-by: Bill Wagner <[email protected]> --------- Co-authored-by: Bill Wagner <[email protected]>
1 parent d1bdb50 commit 10dd246

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
description: "Learn more about: FS0410: A type is less accessible than the value, member or type it is used in"
3+
title: "Compiler error FS0410"
4+
ms.date: 10/12/2025
5+
f1_keywords:
6+
- "FS0410"
7+
helpviewer_keywords:
8+
- "FS0410"
9+
---
10+
11+
# FS0410: A type is less accessible than the value, member or type it is used in
12+
13+
This message is given when you use a type that is less [accessible](../access-control.md) than the value, member or type it is used in.
14+
15+
For example:
16+
17+
[!code-fsharp[FS0410-less-accessible-type](~/samples/snippets/fsharp/compiler-messages/fs0410.fsx#L8-L11)]
18+
19+
Notice that in this example, the type `Person` is `private`, but the function `_getName` is `public`. Also, the function `_getName` uses the type `Person` in its signature, which is not allowed since `Person` is less accessible than `_getName`.
20+
21+
The example above causes the compiler to display the following message:
22+
23+
```text
24+
FS0410: The type 'Person' is less accessible than the value, member or type 'val _getName: p: Person.Person -> string' it is used in.
25+
```
26+
27+
A workaround would be changing the `Person` type to public accessibility, or the `_getName` function to private accessibility.

docs/fsharp/language-reference/compiler-messages/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@
2121
href: ./fs0052.md
2222
- name: FS0067 - This type test or downcast will always hold
2323
href: ./fs0067.md
24+
- name: FS0410 - A type is less accessible than the value, member or type it is used in
25+
href: ./fs0410.md
2426
- name: FS0703 - Expected type parameter, not unit-of-measure parameter
2527
href: ./fs0703.md
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(*
2+
Compiler error: The type %s is less accessible than the value, member or type %s it is used in
3+
4+
Notice that in this example, the type Person is private, but the function _getName is public by default.
5+
Also, the function _getName uses the type Person in its signature, which is not allowed since Person is
6+
less accessible than _getName.
7+
*)
8+
module Person =
9+
type private Person = { Name: string; Email: string }
10+
11+
let _getName (p: Person) = p.Name

0 commit comments

Comments
 (0)