Skip to content

FS0073: internal error: Undefined or unsolved type variable when using records with generic type variables and overloaded operators in inline function #9416

@idars

Description

@idars

When defining a set of generic Vector types, I came across this error after adding an inline function that internally uses an overloaded operator (e.g. op_Addition as in the example below) that take a vector and a constant ('T).

Repro steps

  1. Run the following code in Visual Studio (F# Interactive):
type Vector<'T> =
    { X: 'T
      Y: 'T }
    static member inline (+) (u, a) =
        { X = u.X + a
          Y = u.Y + a }

module Vector =
    let inline add (vector: Vector<'T>) amount =
        vector + amount

Expected behavior

Should presumably not throw an internal error.

Actual behavior

F# encounters an internal error:

> error FS0073: internal error: Undefined or unsolved type variable: ^_?16934

Known workarounds

Any of the following steps prevent the internal error from occurring:

  • Avoiding the overloaded operator
  • Using a unary operator instead of a binary operator
  • Removing the inline function
  • Constraining the type variable of amount
  • Not using a generic type variable for Vector

Related information

  • Operating system - Windows 10
  • F# 4.7.2
  • .NET Runtime kind - .NET Core 3.1
  • Editing Tools - Visual Studio 2019 16.5.3

Possibly related issue: #6648

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FSIBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions