Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw on invalid input in Graph construction #16575

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/Compiler/Driver/GraphChecking/FileContentMapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let visitSynModuleDecl (decl: SynModuleDecl) : FileContentEntry list =
| SynModuleDecl.NestedModule(moduleInfo = SynComponentInfo(longId = [ ident ]; attributes = attributes); decls = decls) ->
yield! visitSynAttributes attributes
yield FileContentEntry.NestedModule(ident.idText, List.collect visitSynModuleDecl decls)
| SynModuleDecl.NestedModule _ -> failwith "A nested module cannot have multiple identifiers"
| SynModuleDecl.NestedModule _ -> () // "A nested module cannot have multiple identifiers"
0101 marked this conversation as resolved.
Show resolved Hide resolved
| SynModuleDecl.Let(bindings = bindings) -> yield! List.collect visitBinding bindings
| SynModuleDecl.Types(typeDefns = typeDefns) -> yield! List.collect visitSynTypeDefn typeDefns
| SynModuleDecl.HashDirective _ -> ()
Expand All @@ -80,7 +80,7 @@ let visitSynModuleSigDecl (md: SynModuleSigDecl) =
| SynModuleSigDecl.NestedModule(moduleInfo = SynComponentInfo(longId = [ ident ]; attributes = attributes); moduleDecls = decls) ->
yield! visitSynAttributes attributes
yield FileContentEntry.NestedModule(ident.idText, List.collect visitSynModuleSigDecl decls)
| SynModuleSigDecl.NestedModule _ -> failwith "A nested module cannot have multiple identifiers"
| SynModuleSigDecl.NestedModule _ -> () // "A nested module cannot have multiple identifiers"
| SynModuleSigDecl.ModuleAbbrev(longId = longId) -> yield! visitLongIdentForModuleAbbrev longId
| SynModuleSigDecl.Val(valSig, _) -> yield! visitSynValSig valSig
| SynModuleSigDecl.Types(types = types) -> yield! List.collect visitSynTypeDefnSig types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,18 @@ module B = C
match content with
| [ TopLevelNamespace "" [ PrefixedIdentifier "C" ] ] -> Assert.Pass()
| content -> Assert.Fail($"Unexpected content: {content}")

[<Test>]
let ``Invalid nested module should just be ignored`` () =
let content =
getContent
false
"""
module A

module B.C
"""

match content with
| [ TopLevelNamespace "" [] ] -> Assert.Pass()
| content -> Assert.Fail($"Unexpected content: {content}")
Loading