【发布时间】:2021-09-05 16:59:58
【问题描述】:
我在使用 F# 在 Visual Studio 中声明类型时遇到问题。一旦我输入 type 关键字,我一输入“type”这个词就会收到两个错误。
main中let关键字下的错误是
Error FS3118 Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword.
[<EntryPoint>]
let main argv =
let x = 7
type Book = { Name: string; Author: string; Rating: int; ISBN: string;}
0 // return an integer exit code
type关键字下的错误是
Error FS0010 Incomplete structured construct at or before this point in expression
我一直在尝试解决此问题,但 FS0010 错误的主要修复只是建议正确缩进代码。我知道代码缩进是正确的,因为如果我去掉 type 关键字并只执行 let x = 7,它就可以正常工作。
我正在使用 Visual Studio 2019。希望得到一些帮助!
【问题讨论】:
-
类型不能在函数内部声明,只能在命名空间或模块中声明(顶层或非顶层)。
标签: f# visual-studio-2019