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 diff --git a/src/Compiler/Driver/GraphChecking/TrieMapping.fs b/src/Compiler/Driver/GraphChecking/TrieMapping.fs index add261d570c..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) @@ -230,7 +231,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..6bd170a9dbf 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -964,4 +964,62 @@ 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 |]) + ] + 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