【问题标题】:The namespace or module is not defined命名空间或模块未定义
【发布时间】:2018-02-10 10:16:12
【问题描述】:

我正在尝试为 F# 处理 getting started docs Visual Studio Code 显示错误

如果我将鼠标悬停在红色曲线上,我会看到错误消息

The Namespace or module ClassLibraryDemo is not defined"

这是 ClassLibaryDemo.fs 的代码

namespace ClassLibraryDemo

module PigLatin =
    let toPigLatin (word: string) =
        let isVowel (c: char) =
            match c with
            | 'a' | 'e' | 'i' |'o' |'u'
            | 'A' | 'E' | 'I' | 'O' | 'U' -> true
            |_ -> false

        if isVowel word.[0] then
            word + "yay"
        else
            word.[1..] + string(word.[0]) + "ay"

【问题讨论】:

  • 当你实际#load ClassLibraryDemo 收到FSI: [Loading c:\Users\*****\Documents\Source\SO2017\SO180207\TestModule.fs] namespace FSI_0002.TestModule val testFunc : unit -> unit 的反馈时,好像看不到文件(可能)。
  • @s952163 我更新了问题以显示交互式终端。你是对的,它无法看到文件。我将名称拼写错误为 ClassLibaryDemo。您想添加您的答案以便我接受吗?

标签: f# visual-studio-code ionide


【解决方案1】:

执行#load ClassLibraryDemo.fs时请查看FSI中的反馈。您应该会看到如下内容:

FSI: [Loading c:\Users\*****\Documents\Source\SO2017\SO180207\TestModule.fs] namespace FSI_0002.TestModule val testFunc : unit -> unit

FSI 很可能找不到您的文件,因为文件名拼写错误或文件位于另一个目录中。可能有其他可能的原因导致无法看到命名空间,例如没有恢复项目,或者缓存损坏(我有一段时间没看到了)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-01
    • 1970-01-01
    • 2020-03-30
    • 1970-01-01
    • 1970-01-01
    • 2019-10-21
    相关资源
    最近更新 更多