Skip to content

update compiler directives page of FSharp reference #47130

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Martin521
Copy link

@Martin521 Martin521 commented Jul 8, 2025

This PR updates the compiler directives page of the FSharp reference according to RFC FS-1146 (scoped nowarn) that was implemented for FSharp 10 here.

Also, the section on conditional directives is updated according this speclet that was implemented for F# 4.0 ten years ago but never found its way into the reference.

/cc @T-Gro


Internal previews

📄 File 🔗 Preview link
docs/fsharp/language-reference/compiler-directives.md docs/fsharp/language-reference/compiler-directives

and  for extended if grammar
@Martin521 Martin521 requested review from BillWagner and a team as code owners July 8, 2025 13:10
@dotnetrepoman dotnetrepoman bot added this to the July 2025 milestone Jul 8, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-fsharp/svc community-contribution Indicates PR is created by someone from the .NET community. labels Jul 8, 2025
Comment on lines 26 to 27
|`#nowarn` *warningcode*|Disables a compiler warning or warnings. To disable multiple warning numbers on the same line, separate each string by a space. <br/> For example: `#nowarn 9 42`<br/> The warning is disabled until eof or until a `#warnon` directive for that same warning number is foud.|
|`#warnon` *warningcode*|Enables a compiler warning (or warnings) that was disabled by a compiler option or by a `#nowarn` directive..<br/> The warning is enabled until eof or until a `#nowarn` directive for that same warning number is found.|
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to list also the #nowarn "42" option (with quotes), since it is what most codebases use?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe include pseudogrammar:

#nowarn (int list | string list) , where strings are without the FS prefix?

Copy link
Author

Choose a reason for hiding this comment

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

I guess I will add a whole section then with more details. I will come back to it.

Copy link
Author

Choose a reason for hiding this comment

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

I added a more detailed section on the warn directives.

In this context I also removed the redundant term "preprocessor directives" from the page. In the F# spec, the term "preprocessor directive" is used only for what in this document is called "conditional compilation directives". Also, the one and only compiler has no separate preprocessor, so "compiler directives" seems to be the right general term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-fsharp/svc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants