fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Augmenting refined types results in an internal error

Open IS4Code opened this issue 7 months ago • 0 comments

Repro steps

[<MeasureAnnotatedAbbreviation>]
type BigInteger<[<Measure>]'M> = System.Numerics.BigInteger with
  static member inline op_Explicit(x : BigInteger<'M>) : System.Numerics.BigInteger = Unchecked.defaultof<_>

Expected behavior

The code should be either parsed as valid, defining a refined type with additional usable members, or it should be properly rejected.

Actual behavior

The code is successfully parsed, but code generation results in

error FS0192: internal error: FindTypeDefBuilder: System.Numerics.BigInteger not found

Known workarounds

Can't think of any workarounds to add members to a refined type that would work in similar contexts normal members do (like SRTPs).

Related information

Tested on 9.0.300 and earlier.

Example: https://sharplab.io/#v2:DYLgZgzgPg2gPAWQKYEMIFcBOSCCA7PAewBcVikATHAI2uwDcBLMxwvAPgF0BYAKGICeAByQACAEKMA5gEk85KUkxx4yNFiRcA5AnaiAvKIDKAiOQC2AOgBy6c0sYBjCJcmz5SRZlEB3RsQALPlFRMxZHUXtzaiVRRjxgeLFCIQB9AFEADyFEx38ACkzREAlpOQUlOB12AEpi41MLGzsHZ1cyjy8DUQBVPEcApEcAa0pLCiQwFHRgYkIwOFT2PiA

IS4Code avatar May 19 '25 16:05 IS4Code