编译时约束以实现完全模式匹配 [英] Compile-time constraint for complete pattern match

查看:61
本文介绍了编译时约束以实现完全模式匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找模式匹配不完整的警告编号。有人知道这是什么吗?

I'm looking for the warning number for incomplete pattern matches. Anyone know what it is?

更全面地讲,我想使FSC.EXE返回不完整的模式匹配作为编译时错误,而不是警告+运行时异常。有人知道这个的警告号码是什么吗?具体来说,这与已编译的.fs /交互式FSI .fsx REPL交互有关。

More fully, I want to make FSC.EXE return incomplete pattern matches as compile-time errors rather than warnings + run-time exceptions. Does anyone know what the warning number for this is? Specifically, this relates to compiled .fs / interactive FSI .fsx REPL interaction.

警告:

Incomplete pattern matches on this expression. For example, the value 'LaLaLa (_)' may indicate a case not covered by the pattern(s).   

如何自定义:

请参见 --warnaserror [+ |-] []

see "--warnaserror[+|-] []"

参考: https://msdn.microsoft.com/zh-CN/library/dd233171(v = vs.140).aspx

推荐答案

使用-warnaserror +:25

要知道是哪一个,我只是使用 let f(Some x)= x 发出了警告,这给了我警告FS0025:不完整的模式与此表达式匹配。对于e
示例,值 None可能表示模式未涵盖的情况。

To know which one it was I simply produced myself the warning using let f (Some x) = x which gaves me warning FS0025: Incomplete pattern matches on this expression. For e xample, the value 'None' may indicate a case not covered by the pattern(s).

这篇关于编译时约束以实现完全模式匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆