Skip to content

Commit

Permalink
Treat exceptions as types in a namespace for graph based type checking (
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed May 30, 2024
1 parent c39cd1a commit 2a65095
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.400.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions src/Compiler/Driver/GraphChecking/TrieMapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
58 changes: 58 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs
Original file line number Diff line number Diff line change
Expand Up @@ -964,4 +964,62 @@ let _ = nameof Task<A.B.C.D>
"""
(set [| 0 |])
]
scenario
"exception syntax in namespace"
[
sourceFile
"A.fs"
"""
namespace Foo
exception internal Blah
"""
Set.empty
sourceFile
"B.fs"
"""
namespace Foo
module Program =
[<EntryPoint>]
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 =
[<EntryPoint>]
let main _ =
raise Blah
0
"""
(set [| 0 |])
]
]

0 comments on commit 2a65095

Please sign in to comment.