1

F# Compiler Messages

 3 years ago
source link: https://brett-rowberry.medium.com/f-compiler-messages-24da6589d796
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
F# Compiler Messages. Well 2020, it’s time for my annual (F#)…

Responses

You have 2 free member-only stories left this month.

Building an F# console app via CLI using the .NET 5 SDK
Building an F# console app via CLI using the .NET 5 SDK
Building an F# console app via CLI using the .NET 5 SDK. Image by Author.

Well 2020, it’s time for my annual (F#) blog post.

I wrote my first FsAdvent post in 2018.

And then I followed up with another post in 2019.

So, what’s happened in my F# world since then? For one, I joined the amazing Quicken Loans so I could do F# full time. It’s been awesome! I also signed up for the most recent round of the F# Software Foundation’s Mentorship Program again — this time as both a mentor and mentee. I think I’ll do one or the other next time!

This year, I’d like to share a small contribution I made to F# documentation and invite you to participate.

Backstory

I was reviewing some code at work recently and I noticed that one of our F# project files was ignoring a few warnings, but I didn’t know what they were. It looked something like this:

F# project file ignoring FS0025

Now imagine we had a code file like this:

F# implementation file with incomplete pattern match

The F# compiler normally yields a warning when it finds an incomplete pattern (not all cases are covered). However, because of the <NoWarn>0025</NoWarn> node in the project file, the build output does not include the warning:

Build succeeded.
0 Warning(s)
0 Error(s)

Without the <NoWarn> node, the build output is:

/somepath/FsAdvent2020.fs(8,11): warning FS0025: Incomplete pattern matches on this expression. For example, the value 'Hot' may indicate a case not covered by the pattern(s). [/somepath/FsAdvent2020.fsproj]
1 Warning(s)
0 Error(s)

Now, how would an F# developer know what FS0025 is? Well, they’re in luck …sort of. If they visit the F# compiler messages page, they’ll see a list of compiler messages. However, it’s far from complete. At the time of this writing, the table of contents looks like this:

Image for post
Image for post
Table of Contents on the F# compiler messages page

How I Contributed

I didn’t know about the F# compiler messages page I mentioned above. I did a web search for a few F# specific errors and landed on a GitHub issue from December 2019, Documentation pages for F# compiler errors like C#. Perfect! Chet Husk did all of the hard work in January 2020. Then, with a little encouragement and guidance, I made some enhancements to the helper script and added message 0025 on incomplete pattern matching:

How You Can Contribute

Good luck, and thank you for contributing to making F# better each and every year!

This post is part of #FsAdvent 2020 organized by Sergey Tihon.
For a listing of all posts, see the
F# Advent Calendar in English 2020.
Thanks, Sergey!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK