Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 873
Print empty namespace or module.#13813
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10360,3 +10360,35 @@ let isFSharpExceptionTy g ty = | ||
| | ValueSome tcref -> tcref.IsFSharpException | ||
| | _ -> false | ||
| let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceContents) = | ||
| match moduleOrNamespaceContents with | ||
| | TMDefs(defs = defs) -> | ||
| let mdDefsLength = | ||
| defs | ||
| |> List.count (function | ||
| | ModuleOrNamespaceContents.TMDefRec _ | ||
| | ModuleOrNamespaceContents.TMDefs _ -> true | ||
| | _ -> false) | ||
| let emptyModuleOrNamespaces = | ||
| defs | ||
| |> List.choose (function | ||
| | ModuleOrNamespaceContents.TMDefRec _ as defRec | ||
| | ModuleOrNamespaceContents.TMDefs(defs = [ ModuleOrNamespaceContents.TMDefRec _ as defRec ]) -> | ||
| match defRec with | ||
| | TMDefRec(bindings = [ ModuleOrNamespaceBinding.Module(mspec, ModuleOrNamespaceContents.TMDefs(defs = defs)) ]) -> | ||
| defs | ||
| |> List.forall (function | ||
| | ModuleOrNamespaceContents.TMDefOpens _ | ||
| | ModuleOrNamespaceContents.TMDefDo _ | ||
| | ModuleOrNamespaceContents.TMDefRec (isRec = true; tycons = []; bindings = []) -> true | ||
| | _ -> false) | ||
| |> fun isEmpty -> if isEmpty then Some mspec else None | ||
| | _ -> None | ||
| | _ -> None) | ||
| if mdDefsLength = emptyModuleOrNamespaces.Length then | ||
| Some emptyModuleOrNamespaces | ||
| else | ||
| None | ||
| | _ -> None | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also check for modulerecFoobardo()namespacerecFoobardo()ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modulerecFoobardo()currently produces moduleFoobarval``doval@3`` :unitThis probably isn't correct but is outside my scope here. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2676,3 +2676,9 @@ type TraitConstraintInfo with | ||
| /// Get the key associated with the member constraint. | ||
| member GetWitnessInfo: unit -> TraitWitnessInfo | ||
| /// Matches a ModuleOrNamespaceContents that is empty from a signature printing point of view. | ||
| /// Signatures printed via the typed tree in NicePrint don't print TMDefOpens or TMDefDo. | ||
| /// This will match anything that does not have any types or bindings. | ||
| val (|EmptyModuleOrNamespaces|_|): | ||
0101 marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) option | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be another edge case which could theoretically happen:
In this case it won't be matched and
namespace Foowon't be in the signatures.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can live with that, the goal is to avoid purely empty file generation.
This will give a result because of the nested module and that is good enough for my use case.