Skip to content

F# 4.1 - Possible regression Op_Dynamic #2416

@mrange

Description

@mrange

When upgrading to VS 2017 and F# 4.1 some of my old projects won't compile with:

error FS0072: 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.

Repro steps

type OpDynamic() =
  static member ( ? ) (x, n) = x
  member x.Prop = 1

[<EntryPoint>]
let main argv = 
  let op  = OpDynamic ()
  let op2 = op?Hello.Prop
  printfn "%A" argv
  0

Expected behavior

Compilation succeed with intended behavior

Actual behavior

Fails with

error FS0072: 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.

Known workarounds

If I change:

  let op2 = op?Hello.Prop

Into

  let op2 = (op?Hello).Prop

it seems to work

Also if I change from:

type OpDynamic() =
  static member ( ? ) (x, n) = x
  member x.Prop = 1
type OpDynamic() =
  member x.Prop = 1

let ( ? ) x n = x

The reason I made Op_Dynamic a member function was that I hoped not to pollute the namespace with global operators. Perhaps a misguided idea.

Related information

  • New F# project, no changes
  • Windows 10 64bit
  • Visual Studio
Microsoft Visual Studio Community 2017 RC
Version 15.0.26206.0 D15REL
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Community

Visual Basic 2017 RC   00369-50000-00000-AA988
Microsoft Visual Basic 2017 RC

Visual C# 2017 RC   00369-50000-00000-AA988
Microsoft Visual C# 2017 RC

Visual C++ 2017 RC   00369-50000-00000-AA988
Microsoft Visual C++ 2017 RC

Visual F# 4.1   00369-50000-00000-AA988
Microsoft Visual F# 4.1

ASP.NET and Web Tools 2017   15.0.30206.0
ASP.NET and Web Tools 2017

Common Azure Tools   1.9
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

NuGet Package Manager   4.0.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Visual Studio tools for CMake   1.0
Visual Studio tools for CMake

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.ReadyRegression

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions