You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GHC版本升级导致Haskell Vulkan项目中width字段歧义编译错误的原因咨询

GHC版本升级导致Haskell Vulkan项目中width字段歧义编译错误的原因咨询

各位好,我正在搭载M2 GPU的MacOS系统上用Haskell开发Vulkan应用,最近遇到了一个版本兼容问题:

我在代码中写了这样一行:

width    = realToFrac (width (swapchainExtent :: Extent2D))

这段代码在GHC 8.10.7版本下能正常编译通过,但升级到GHC 9.6.3后,直接抛出了字段歧义的编译错误,具体报错信息如下:

/Users/liuzichao/Hulkan/test/Main.hs:283:40: error:
Ambiguous occurrence ‘width’
It could refer to
either the field ‘width’ of record ‘Viewport’,
imported from ‘Vulkan.Core10’ at test/Main.hs:36:1-30
(and originally defined in ‘Vulkan.Core10.Pipeline’)
or the field ‘width’ of record ‘FramebufferCreateInfo’,
imported from ‘Vulkan.Core10’ at test/Main.hs:36:1-30
(and originally defined in ‘Vulkan.Core10.Pass’)
or the field ‘width’ of record ‘Extent3D’,
imported from ‘Vulkan.Core10’ at test/Main.hs:36:1-30
(and originally defined in ‘Vulkan.Core10.FundamentalTypes’)
or the field ‘width’ of record ‘Extent2D’,
imported from ‘Vulkan.Core10’ at test/Main.hs:36:1-30
(and originally defined in ‘Vulkan.Core10.FundamentalTypes’)
|

, width = realToFrac (width (swapchainExtent :: Extent2D))

我想请教大家,为什么会出现这种差异?GHC 9.6.3和8.10.7在类型推断、字段解析逻辑上有什么不同吗?

备注:内容来源于stack exchange,提问作者zichao liu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 11:08:02