为什么第二次在FSI中执行此代码会崩溃?

时间:2017-07-25 22:41:26

标签: dictionary f# fsi

我有一些代码会生成一个异常second time它在FSI中执行。顺序如下:

1)选择所有行above,使用FSIAlt+Enter上运行。

2)选择代码,使用FSIAlt+Enter上运行。到目前为止没有错误。

3)点击Alt+Enter再次运行所选代码。错误(见下文)。

以下是产生此行为的代码行:

let assetsMap =
    assetInfo.Rows
    |> Seq.filter (fun (rw: AssetsInfo.Row) -> Set.contains rw.Ticker assetsTickerSet)
    |> List.ofSeq
    |> List.map (fun rw -> rw.Ticker, Asset.constructor rw) // Frame.ReadCSV called here
    |> Map.ofSeq

相关信息:

type AssetsInfo = FSharp.Data.CsvProvider<...> 

错误讯息:

System.InvalidOperationException: tried to skip The input sequence has an insufficient number of elements. 1 past the end of the seq
   at Microsoft.FSharp.Collections.SeqModule.Skip@1316.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at FSharp.Data.Runtime.CsvHelpers.parseIntoTypedRows@176.GenerateNext(IEnumerable`1& next) in C:\Git\FSharp.Data\src\Csv\CsvRuntime.fs:line 176
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.Internal.IEnumerator.next@187[T](FSharpFunc`2 f, IEnumerator`1 e, FSharpRef`1 started, Unit unitVar0)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.filter@182.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at <StartupCode$FSI_0035>.$FSI_0035.main@() in H:\Dropbox\BitBucket\VSProjects\Fractal10\Fractal10\Program.fs:line 139
Stopped due to error

关于这种奇怪行为的原因的任何想法?

0 个答案:

没有答案