1
使用Visual Studio 2015 Update 3及fsi.exe
我試圖運行此腳本:#如果 - 的#else - #ENDIF從F#4.0版打破F#腳本
//error.fsx
#if INTERACTIVE
let msg = "Interactive"
#else
let msg = "Not Interactive"
#endif
let add x y =
x + y
printfn "%d" (add 1 2)
輸出:error.fsx (12,15):錯誤FS0039:價值或構造的 '添加' 沒有定義
如果我再註釋掉#if
- #else
- #endif
塊,它工作正常:
// fixed.fsx
//#if INTERACTIVE
// let msg = "Interactive"
//#else
// let msg = "Not Interactive"
//#endif
let add x y =
x + y
printfn "%d" (add 1 2)
輸出:
我敢肯定,我做錯了什麼(而不是這個是一個錯誤),但我不能爲我的生活弄清楚如何使這一工作。
想法?
感謝Tomas!只要你指出這是有道理的。我從[這裏](http://brandewinder.com/2016/02/02/06-fsharp-scripting-tips/)抓取了示例代碼(#3),並假定它能夠像這樣工作。非常感謝! –
這是一個有趣的錯誤 - 我花了一點時間來弄清楚發生了什麼,我認爲這是一個錯誤(至少在錯誤報告中)。 –
馬特克萊恩:對不起!我會修復這個帖子,可能有些格式化會在那裏發生。 – Mathias