3
votes

I'm using F# 3.1 on VS2013. The following code causes the following error message

"Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.".

I cannot figure out why this happens since all types used here are well-known (from .Net framework itself). Can anyone shed me light please?

open System.IO
open System.Collections.Generic

type A() as me =
    let drives = new List<DriveInfo>()

    let x = me.SelectedDrive
    let y = x.RootDirectory     // this causes "Lookup on object of indeterminate type..."

    member this.SelectedDrive with get() = drives.[0]
1

1 Answers

3
votes

F# compiler reads the file in top-to-bottom direction, so when type of y has to be determined, type of this.SelectedDrive is not yet known to the compiler. That's why you're getting this error.