【发布时间】:2020-01-31 10:40:07
【问题描述】:
在 Common.fs 中:
namespace Bug
module Common =
type SourceEntity = {
id : int
link : string
}
type ReleaseEntity = {
id : int
notes : string
}
在 Release.fs 中
namespace Bug
open System
open Common
module Release =
let cache = new Collections.Generic.Dictionary<int, ReleaseEntity>()
let AddToCache(entity) =
cache.Add(entity.id, entity)
()
let AddRec() =
let entity : ReleaseEntity = {
id = 1
notes = "Notes"
}
AddToCache(entity)
在 Source.fs 中
namespace Bug
open System
open Common
module Source =
let Cache = new Collections.Generic.Dictionary<int, SourceEntity>()
let AddToCache(entity) =
Cache.Add(entity.id, entity) <<=== E R R O R
()
let AddRec() =
let ent : SourceEntity = {
id = 1
releases = "Releases"
}
AddToCache(ent) <<=== E R R O R
Visual Studio 项目中按上述顺序包含的文件。
Source.fs 中报告的错误:
错误 FS0001 此表达式应具有类型
'源实体'
但这里有类型
'释放实体'
如果Common.fs中两种类型的顺序颠倒,Release.fs中报错,期望类型为ReleaseEntity但类型为SourceEntity。
任何想法为什么会发生此错误?
【问题讨论】:
标签: f#