ghc 是否可以将某些指定的警告视为错误,而将其他警告视为警告?
是否可以以某种方式说服 ghc 将某些类型的警告视为错误,将其他类型的警告视为警告,同时仍然报告它们?
我希望,这样的事情是可能的:
ghc -Werror -fwarn-missing-methods -Wwarn -fwarn-missing-signatures
,但我没有运气。 (我认为 gcc 也不支持这一点。)
Can ghc somehow be convinced to treat certain types of warnings as errors and others as warnings, while still reporting them?
I hoped, this would be possible with something like this:
ghc -Werror -fwarn-missing-methods -Wwarn -fwarn-missing-signatures
, but I had no luck with that. (I think gcc doesn't support this either.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请注意,从 GHC 8.2.1 开始,此功能已存在! Trac Ticket #11219 对此进行了描述,现在您可以执行
ghc -Werror=missing-methods -Wmissing-signatures
!Note that starting GHC 8.2.1, this feature exists! It was described by Trac ticket #11219 and now you can do
ghc -Werror=missing-methods -Wmissing-signatures
!不,这是一个全有或全无的转变。然而,你可以这样做,
虽然这会导致 GHC 完全吞下警告,但这可能不是你想要的。
No, it's an all-or-nothing switch. However, you can do
Although this causes GHC to swallow the warning completely, which might not be what you wanted.
如果这是一个非常令人担忧的问题,您可以考虑在每个模块的基础上启用和禁用警告。因此,在某些模块中,您必须:
到这里了解所有内容,而在其他模块中:
只启用某些内容作为错误。
If this is of great concern, you could consider enabling and disabling warnings on a per-module basis. So that in some modules you'd have:
to here about everything, while in others:
to only enable some things as errors.