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
- 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