Skip to content

F# 4.1 - Possible regression Op_Dynamic #2416

Closed

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

Activity

  1. dsyme commented on Feb 23, 2017

    @dsyme
    Contributor

    @cartermp We should look into this. I'm not aware of the specific change that would have caused this regression.....

  2. added this to the milestone on Feb 23, 2017
  3. cartermp commented on Feb 23, 2017

    @cartermp
    Contributor

    Tagged and noted for blog post. I'll see if I can get it into the known issues for the VS release notes as well.

  4. added
    Impact-High
    on Mar 14, 2017
  5. dsyme commented on Apr 7, 2017

    @dsyme
    Contributor

    @gusty, This bug is caused by my switching of operations in the commit 4f89b4c when fixing #1306 as part of #1278

    We need to go back and review what we've done here, and perhaps revert the change

  6. gusty commented on Apr 7, 2017

    @gusty
    Contributor

    @dsyme
    Hopefully we don't revert it, otherwise it will also be a regression now.
    I would like to help to resolve this in a way we don't need to revert but I'll be out for holidays.
    In the meantime let me know if you see other regressions related to this issue.

  7. dsyme commented on Apr 7, 2017

    @dsyme
    Contributor

    @gusty I submitted a tentative fix here #2816

  8. added a commit that references this issue on Apr 26, 2017
  9. dsyme commented on Apr 29, 2017

    @dsyme
    Contributor

    The fix for this has been merged

  10. modified the milestones: , 15.3 on Jun 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-HighReadyRegression

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions