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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Fix spurious FS0410 accessibility error when tuple-deconstructing bindings use private types in the same module scope. ([Issue #4161](https://github.com/dotnet/fsharp/issues/4161), [PR #19947](https://github.com/dotnet/fsharp/pull/19947))
* Fix internal error (FS0193) when calling an indexed property setter with a named argument that matches an indexer parameter. ([Issue #16034](https://github.com/dotnet/fsharp/issues/16034), [PR #19851](https://github.com/dotnet/fsharp/pull/19851))
* Fix missing FS1182 ("unused binding") warning for unused `let` function bindings inside class types. ([Issue #13849](https://github.com/dotnet/fsharp/issues/13849), [PR #19805](https://github.com/dotnet/fsharp/pull/19805))
* Fix inner mutually-recursive `let rec ... and ...` functions under `--realsig+` not being lifted to top-level static methods (TLR), causing `FSharpFunc` closure allocations and loss of `tail.` opcodes — the large struct-mutual-recursion perf regression reported in [Issue #17607](https://github.com/dotnet/fsharp/issues/17607). ([PR #19882](https://github.com/dotnet/fsharp/pull/19882))
Expand Down
13 changes: 8 additions & 5 deletions src/Compiler/Checking/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ let AccessInternalsVisibleToAsInternal thisCompPath internalsVisibleToPaths acce
accessSubstPaths (thisCompPath, internalsVisibleToPath) access)


let CheckTypeForAccess (cenv: cenv) env objName valAcc m ty =
let CheckTypeForAccess (cenv: cenv) env objName valAcc skipAccessibilityCheckForCompilerGeneratedVal m ty =
if cenv.reportErrors then

let visitType ty =
Expand All @@ -531,7 +531,7 @@ let CheckTypeForAccess (cenv: cenv) env objName valAcc m ty =
| ValueSome tcref ->
let thisCompPath = compPathOfCcu cenv.viewCcu
let tyconAcc = tcref.Accessibility |> AccessInternalsVisibleToAsInternal thisCompPath cenv.internalsVisibleToPaths
if isLessAccessible tyconAcc valAcc then
if not skipAccessibilityCheckForCompilerGeneratedVal && isLessAccessible tyconAcc valAcc then
errorR(Error(FSComp.SR.chkTypeLessAccessibleThanType(tcref.DisplayName, objName()), m))

CheckTypeDeep cenv (visitType, None, None, None, None) cenv.g env NoInfo ty
Expand Down Expand Up @@ -2111,7 +2111,10 @@ and CheckBinding cenv env alwaysCheckNoReraise ctxt (TBind(v, bindRhs, _) as bin
// Check accessibility
if (v.IsMemberOrModuleBinding || v.IsMember) && not v.IsIncrClassGeneratedMember then
let access = AdjustAccess (IsHiddenVal env.sigToImplRemapInfo v) (fun () -> v.DeclaringEntity.CompilationPath) v.Accessibility
CheckTypeForAccess cenv env (fun () -> NicePrint.stringOfQualifiedValOrMember cenv.denv cenv.infoReader vref) access v.Range v.Type
// Compiler-generated patternInput temps are module-init scaffolding; their promoted
// accessibility does not reflect the enclosing binding scope (dotnet/fsharp#4161).
let skipAccessibilityCheck = v.IsCompilerGenerated && v.LogicalName.StartsWith("patternInput")
CheckTypeForAccess cenv env (fun () -> NicePrint.stringOfQualifiedValOrMember cenv.denv cenv.infoReader vref) access skipAccessibilityCheck v.Range v.Type

if cenv.reportErrors then

Expand Down Expand Up @@ -2336,7 +2339,7 @@ let CheckRecdField isUnion cenv env (tycon: Tycon) (rfield: RecdField) =
IsHiddenTyconRepr env.sigToImplRemapInfo tycon ||
(not isUnion && IsHiddenRecdField env.sigToImplRemapInfo (tcref.MakeNestedRecdFieldRef rfield))
let access = AdjustAccess isHidden (fun () -> tycon.CompilationPath) rfield.Accessibility
CheckTypeForAccess cenv env (fun () -> rfield.LogicalName) access m fieldTy
CheckTypeForAccess cenv env (fun () -> rfield.LogicalName) access false m fieldTy

if isByrefLikeTyconRef g m tcref then
// Permit Span fields in IsByRefLike types
Expand Down Expand Up @@ -2616,7 +2619,7 @@ let CheckEntityDefn cenv env (tycon: Entity) =

// Access checks
let access = AdjustAccess (IsHiddenTycon env.sigToImplRemapInfo tycon) (fun () -> tycon.CompilationPath) tycon.Accessibility
let visitType ty = CheckTypeForAccess cenv env (fun () -> tycon.DisplayNameWithStaticParametersAndUnderscoreTypars) access tycon.Range ty
let visitType ty = CheckTypeForAccess cenv env (fun () -> tycon.DisplayNameWithStaticParametersAndUnderscoreTypars) access false tycon.Range ty

abstractSlotValsOfTycons [tycon] |> List.iter (typeOfVal >> visitType)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,38 @@ module Tuple =
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes = [|"tuples02.fs"|])>]
let ``Tuple - tuples02_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> compileExeAndRun
|> shouldSucceed

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes = [|"tuples03.fs"|])>]
let ``Tuple - tuples03_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics [
Error 410, Line 6, Col 12, Line 6, Col 14, "The type 'T' is less accessible than the value, member or type 'val t': T' it is used in."
Error 410, Line 6, Col 9, Line 6, Col 10, "The type 'T' is less accessible than the value, member or type 'val t: T' it is used in."
]

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes = [|"tuples04.fs"|])>]
let ``Tuple - tuples04_fs - --test:ErrorRanges`` compilation =
compilation
|> asFs
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics [
Error 410, Line 6, Col 12, Line 6, Col 14, "The type 'T' is less accessible than the value, member or type 'val internal t': T' it is used in."
Error 410, Line 6, Col 9, Line 6, Col 10, "The type 'T' is less accessible than the value, member or type 'val internal t: T' it is used in."
]

// This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Tuple)
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes = [|"W_IncompleteMatches01.fs"|])>]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module PM =
type PT =
abstract A : int
let a = { new PT with member __.A = 1 }
let b, c =
{ new PT with member __.A = 1 }
, { new PT with member __.A = 1 }

module private PM2 =
type PT =
abstract A : int
let a = { new PT with member __.A = 1 }
let b, c =
{ new PT with member __.A = 1 }
, { new PT with member __.A = 1 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace N

type internal T = T

module public M =
let t, t' = T, T
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace N

type private T = T

module internal M =
let t, t' = T, T
Loading