From 7820491ab1d192296a0702cb64e98c48fd0c7783 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 30 May 2024 09:46:50 +0200 Subject: [PATCH 1/3] Treat exceptions in namespaces like types in TrieMapping.fs --- .../Driver/GraphChecking/TrieMapping.fs | 3 ++- .../TypeChecks/Graph/Scenarios.fs | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Driver/GraphChecking/TrieMapping.fs b/src/Compiler/Driver/GraphChecking/TrieMapping.fs index add261d570c..edc877b9526 100644 --- a/src/Compiler/Driver/GraphChecking/TrieMapping.fs +++ b/src/Compiler/Driver/GraphChecking/TrieMapping.fs @@ -230,7 +230,8 @@ let rec mkTrieNodeFor (file: FileInProject) : FileIndex * TrieNode = let hasTypesOrAutoOpenNestedModules = List.exists (function - | SynModuleDecl.Types _ -> true + | SynModuleDecl.Types _ + | SynModuleDecl.Exception _ -> true | SynModuleDecl.NestedModule(moduleInfo = SynComponentInfo(attributes = attributes)) -> isAnyAttributeAutoOpen attributes | _ -> false) diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs index 12b13b88beb..2aa3ccf9043 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -961,6 +961,31 @@ module Z open System.Threading.Tasks let _ = nameof Task +""" + (set [| 0 |]) + ] + scenario + "exception syntax in namespace" + [ + sourceFile + "A.fs" + """ +namespace Foo + +exception internal Blah +""" + Set.empty + sourceFile + "B.fs" + """ +namespace Foo + +module Program = + + [] + let main _ = + raise Blah + 0 """ (set [| 0 |]) ] From fedd2b3ea00df9e394fd5ac4d240ce2ce774256f Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 30 May 2024 09:51:32 +0200 Subject: [PATCH 2/3] Treat exceptions in signature namespaces like types in TrieMapping.fs --- .../Driver/GraphChecking/TrieMapping.fs | 3 +- .../TypeChecks/Graph/Scenarios.fs | 35 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Driver/GraphChecking/TrieMapping.fs b/src/Compiler/Driver/GraphChecking/TrieMapping.fs index edc877b9526..7eeb40108bd 100644 --- a/src/Compiler/Driver/GraphChecking/TrieMapping.fs +++ b/src/Compiler/Driver/GraphChecking/TrieMapping.fs @@ -215,7 +215,8 @@ let rec mkTrieNodeFor (file: FileInProject) : FileIndex * TrieNode = let hasTypesOrAutoOpenNestedModules = decls |> List.exists (function - | SynModuleSigDecl.Types _ -> true + | SynModuleSigDecl.Types _ + | SynModuleSigDecl.Exception _ -> true | SynModuleSigDecl.NestedModule(moduleInfo = SynComponentInfo(attributes = attributes)) -> isAnyAttributeAutoOpen attributes | _ -> false) diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs index 2aa3ccf9043..6bd170a9dbf 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -988,5 +988,38 @@ module Program = 0 """ (set [| 0 |]) - ] + ] + scenario + "exception syntax in namespace signature" + [ + sourceFile + "A.fsi" + """ +namespace Foo + +exception internal Blah +""" + Set.empty + sourceFile + "A.fs" + """ +namespace Foo + +exception internal Blah +""" + (set [| 0 |]) + sourceFile + "B.fs" + """ +namespace Foo + +module Program = + + [] + let main _ = + raise Blah + 0 +""" + (set [| 0 |]) + ] ] \ No newline at end of file From 455b85f52ec80a19fe40bbb4f77c93030e7ee0ef Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 30 May 2024 09:58:30 +0200 Subject: [PATCH 3/3] Add release note --- docs/release-notes/.FSharp.Compiler.Service/8.0.400.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md index 744d041341e..7180cc1aef8 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md @@ -15,6 +15,7 @@ * Fix state machines compilation, when big decision trees are involved, by removing code split when resumable code is detected ([PR #17076](https://github.com/dotnet/fsharp/pull/17076)) * Fix for exponential runtime in CE builders when using nested implicit yields [PR #17096](https://github.com/dotnet/fsharp/pull/17096) * Fix several AND operator parser bugs and regressions ([Issue #16447](https://github.com/dotnet/fsharp/issues/16447), [Issue #17134](https://github.com/dotnet/fsharp/issues/17134), [Issue #16309](https://github.com/dotnet/fsharp/issues/16309), [PR #17113](https://github.com/dotnet/fsharp/pull/17113)) +* Treat exceptions as types in a namespace for graph based type checking ([Issue #17262](https://github.com/dotnet/fsharp/issues/17262), [PR #17268](https://github.com/dotnet/fsharp/pull/17268)) ### Added