Skip to content

RequireQualifiedAccess section#39

Merged
bartelink merged 6 commits intofsprojects:masterfrom
IanWitham:RequireQualifiedAccess
Mar 23, 2026
Merged

RequireQualifiedAccess section#39
bartelink merged 6 commits intofsprojects:masterfrom
IanWitham:RequireQualifiedAccess

Conversation

@IanWitham
Copy link
Copy Markdown
Contributor

Added section for RequireQualifiedAccess, plus slight editing of the preceding "AutoOpen" paragraph, per #31

@IanWitham IanWitham marked this pull request as draft March 18, 2025 00:43
@IanWitham IanWitham closed this Mar 18, 2025
@IanWitham IanWitham reopened this Mar 18, 2025
@IanWitham IanWitham marked this pull request as ready for review March 18, 2025 08:11
Comment thread docs/fsharp-cheatsheet.md
statements to avoid pitfalls; `AutoOpen` would sidestep this.
#### Use `AutoOpen` and/or ignore `RequireQualifiedAccess` best practice with caution!

Functions with identical names from different modules will silently "shadow" each other, causing the most recently imported definition to be used instead of the one you might expect. **The compiler will _not_ warn you that this has happened.** Even if your code works, you may encounter compiler errors if the `open` order changes. A [coding convention (MS Learn)](https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/conventions#sort-open-statements-topologically) exists for `open` statements to avoid pitfalls.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this warning about silent meaning changes is not inaccurate, but I can imagine it scaring people into thinking they might as well be using something typeless. I dont know how I'd convey it, but the only real problem it triggers is inferring the wrong type where it's not pinned, which then manifests as an error some distance away in terms of files or compile time.

Copy link
Copy Markdown
Member

@bartelink bartelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I like this - just added a pondering comment

Comment thread docs/fsharp-cheatsheet.md Outdated
@bartelink bartelink merged commit 0b59ee2 into fsprojects:master Mar 23, 2026
@bartelink
Copy link
Copy Markdown
Member

Thanks @IanWitham for a very useful contribution; apologies for the long delay before merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants