dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.87k stars 781 forks source link

FS0001 reported instead of FS0722 #7018

Open Happypig375 opened 5 years ago

Happypig375 commented 5 years ago

I shouldn't be able to create multi-case parameterized active patterns. However, the error in this case is not obvious at all.

Repro steps

let (|LesserThan|EqualTo|GreaterThan|) target value = if value < target then LesserThan elif value > target then GreaterThan else EqualTo
let clamp = function (LesserThan 2) -> min | (GreaterThan 3) -> max | x -> x

Expected behavior

error FS0722: Only active patterns returning exactly one result may accept arguments

Actual behavior

error FS0001: Type mismatch. Expecting a
    ''a -> Choice<'b,'c,'d>'    
but given a
    ''a -> 'a -> Choice<unit,unit,unit>'    
The type 'Choice<'a,'b,'c>' does not match the type ''d -> Choice<unit,unit,unit>'
Related information Microsoft Visual Studio Community 2019 Version 16.1.3 VisualStudio.16.Release/16.1.3+29009.5 Microsoft .NET Framework Version 4.7.03056 Installed Version: Community Visual C++ 2019 00435-60000-00000-AA419 Microsoft Visual C++ 2019 Application Insights Tools for Visual Studio Package 9.1.00429.1 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2019 16.1.429.50124 ASP.NET and Web Tools 2019 Azure App Service Tools v3.0.0 16.1.429.50124 Azure App Service Tools v3.0.0 C# Tools 3.1.1-beta4-19281-06+58a4b1e79aea28115e66b06f850c83a3f1fcb6d3 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Extensibility Message Bus 1.1.77 (master@24013d5) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio 16.1.1 (2473f22) Support for debugging Mono processes with Visual Studio. NuGet Package Manager 5.1.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees. TypeScript Tools 16.0.10506.2004 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.1.1-beta4-19281-06+58a4b1e79aea28115e66b06f850c83a3f1fcb6d3 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 10.4 for F# 4.6 16.1.0-beta.19253.3+42526fe359672a05fd562dc16a91a43d0fe047a7 Microsoft Visual F# Tools 10.4 for F# 4.6 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Tools for Unity 4.1.1.0 Visual Studio Tools for Unity VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.1.0.543 (d16-1@34a619991) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.1.0.418 (remotes/origin/d16-1@5b958bb10) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.2.112 (4db4af4) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 9.3.0.22 (HEAD/8e7764fdf) Xamarin.Android Reference Assemblies and MSBuild support. Mono: mono/mono/2018-08@3cb36842fc4 Java.Interop: xamarin/java.interop/d16-1@5ddc3e3 LibZipSharp: grendello/LibZipSharp/d16-1@44de300 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-1@acabd26 Xamarin.iOS and Xamarin.Mac SDK 12.10.0.153 (750a879) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
dsyme commented 4 years ago

Yes this error message could be improved