让我们在下面采用类型的扩充滥用 F#脚本:
type AugmentMe = val _i : int
type AugmentMe with member i.I = i._i
type AugmentMe with new(i) = { _i = i }
printfn "AugmentMe instance: %i" (AugmentMe(42).I)
当被解释为一个整体时,产生预期的Fsi
输出:
>
AugmentMe instance: 42
type AugmentMe =
class
new : i:int -> AugmentMe
val _i: int
member I : int
end
val it : unit = ()
现在,如果我们重置Fsi
会话并解释相同的脚本,但这次是逐行的,那么Fsi
无法为最后两个脚本添加具有以下诊断的类型构造函数行:
>
type AugmentMe =
class
val _i: int
end
>
type AugmentMe with
member I : int
>
~vs7894.fsx(3,30): warning FS0073: internal error: pop on empty stack during code generation, methodName = AugmentMe..ctor, m = C:\Users\gene\AppData\Local\Temp\~vs7894.fsx(3,29)-(3,39)
type AugmentMe with
new : i:int -> AugmentMe
>
~vs7894.fsx(4,35): error FS0039: The value or constructor 'AugmentMe' is not defined
经过一些谷歌搜索后,2011年左右的following mentioning突然出现了,但显然神器仍然存在。
是什么给出的?我应该把它报告给fsbugs吗? 谢谢。