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

