dotnet / dotnet/fsharp

Augmenting refined types results in an internal error

Open
#18,574 0 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Bug
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

**Repro steps**

```fs
[]
type BigInteger<[]'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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.