完整模式匹配的编译时约束 [英] Compile-time constraint for complete pattern match

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

问题描述

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

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[+|-] []"

ref: https://msdn.microsoft.com/en-us/library/dd233171(v=vs.140).aspx

推荐答案

use --warnaserror+:25

要知道是哪一个,我只是使用 let f (Some x) = x 给自己生成了警告,这给了我 警告 FS0025:此表达式上的模式匹配不完整.前面例如,值无"可能表示模式未涵盖的情况.

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天全站免登陆