dotnet / dotnet/fsharp

`internal error: no 'value__' field found for enumeration type` when `rec` module & `enum` constraint & type alias

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

Description

**Repro & Behaviour**

```fsharp
module rec MyModule

type MyEnum =
| Alpha = 1
| Beta = 2
type MyInter<'TEnum when 'TEnum : enum> = interface end

type MyAlias = MyInter
```
([Fable repl](https://fable.io/repl/#?code=LYewJgrgNgpgBAJxgYzgWQJ5vNGBYAKEIBcMAHeTAUQDsJg4BeQuOAHzgEEoyALAQyZwAjC3ZwAQjGKDGcAEwlylDAEkaxGAgA8AcgAqtenADuvGDTgGjDAFxwL9bQEsNAPjdDXmhADN+yPAWYIRKFOgY3M78AM5CmOo+2tR0wG5AA&html=Q&css=Q))

produces compiler error: (on `MyEnum` in `type MyEnum =`)
> error FS0073: internal error: no 'value__' field found for enumeration type MyEnum

Expected behaviour: should compile without any errors

**Additional info**:
* Same behaviour for `namespace rec` instead of `module rec` ([repl](https://fable.io/repl/#?code=HYQwtgpgzgDiDGEAEAnC8kFkCemD2AJgK4A2EAsAFBUAu2MyOAosEWEgLxVJIA+SAQRIwAFiE5IAjNz5IAQhBriOSAEy16jbAElgNCCgA8AcgAqLNkgDuIiMCRmL7AFxI7bQwEs9APh8TvfRQAMwRkOwIqDQYsbCFPECgJHF0gw2ZWMB8gA&html=Q&css=Q))
* It does compile without `rec` ([module (repl)](https://fable.io/repl/#?code=LYewJgrgNgpgBAWQJ4PNGBYAUNgLkgB3mQFEA7CYOAXmzjgB84BBKAgCwEMa4BGOxnABCMXN2pwATHkLEkASTK4YAJwA8AcgAq5SnADu7GGTjbdVAFxxjlNQEslAPkc8HylQDNOAY3jGw2DJEiEisdpwAzjzIiu5qpBTAjkA&html=Q&css=Q), [namespace (repl)](https://fable.io/repl/#?code=HYQwtgpgzgDiDGEAEBZAnig9gEwK4BsIBYAKFIBc0Zl0BRYXMJAXlKSQB8kBBfGACxAskARjackAIQjkhzJACYKVGmgCSwchABOAHgDkAFXqMkAd34RgSIyaYAuJFca6AlpoB8H4e63aAZgjIVtikytSoaLyuIFDC6Bp+unQMYB5AA&html=Q&css=Q))
* It does compile without `enum` constraints ([repl](https://fable.io/repl/#?code=LYewJgrgNgpgBAJxgYzgWQJ5vNGBYAKEIBcMAHeTAUQDsJg4BeQuOAHzgEEoyALAQyZwAjC3ZwAQjGKDGcAEwlylDAEkaxGAgA8AcgAqtegD4hASw1aAZv2TwYNMISUV0Gbmf4BnIZnWadajpgYyA&html=Q&css=Q))
* Same error when used in interface or class inheritance ([interface (repl)](https://fable.io/repl/#?code=LYewJgrgNgpgBAJxgYzgWQJ5vNGBYAKEIBcMAHeTAUQDsJg4BeQuOAHzgEEoyALAQyZwAjC3ZwAQjGKDGcAEwlylDAEkaxGAgA8AcgAqtenADuvGDTgGjDAFxwL9bQEsNAPjdDXmhADN+yPAWYIRKFHCqTGKsruYIzsToahpa2tR0wG6EQA&html=Q&css=Q), [class (repl)](https://fable.io/repl/#?code=LYewJgrgNgpgBAJxgYzgWQJ5vNGBYAKEIBcMAHeTAUQDsJg4BeQuOAHzgEEoyALAQyZwAjC3ZwAQjGKDGcAEwlylDAEkaxGAgA8AcgAqtenADuvGDTgGjDAFxwL9bQEsNAPjdDXmhADN+yPAWYIRKFHAAwnAAFACUTGKs3lr+gehqGlra1HTAboRAA&html=Q&css=Q))
* It does compile when `MyInter` is used in other places (like type annotation) ([repl](https://fable.io/repl/#?code=LYewJgrgNgpgBAJxgYzgWQJ5vNGBYAKEIBcMAHeTAUQDsJg4BeQuOAHzgEEoyALAQyZwAjC3ZwAQjGKDGcAEwlylDAEkaxGAgA8AcgAqtenADuvGDTgGjDAFxwL9bQEsNAPjdDXmhADN+yPAWYISEsMRwAG7C9pjqPtrUdMCecv7OUCbOxLxwAER5YdJR8rFqGlqJGDapcADecDQwJujlCUn0ngC+oQThcL7CcAAUkWXxlR0pAJRw4xU6U7WRikQEpBRwAKpCHABqcCC+rROL1cluvUURvnqCZhZWgvaOwC7unsMw9rr8s3LDabXAaRIS+YZTAB03D4f2BvmOaSqNUIQA&html=Q&css=Q))
* It does compile when Enum & Alias are in different modules (-> not in same `rec` module) ([repl](https://fable.io/repl/#?code=LYewJgrgNgpgBAJxgYzgWQJ5vNeBeAWAChi4y4AXDAB3kwFEA7CYOQo8uAHzgEEpqACwCGbOAEZS5HgCEYFUXjgAmKWSq10GAJKMKMBAB4A5ABUmLOAHdBMRnDMXWALjh2WhgJZ6AfD7He+ggAZsLI8HZgxMQgtPaY2JCwxBp0GPyewgDOYpi6QYYMzMA+xEA&html=Q&css=Q))

**Known workarounds**

* Don't use `rec` module/namespace
* Extract Enum or its usage into different module
* Don't use `enum` constraint

**Related information**

* `dotnet --version`: 7.0.101
(linked examples (Fable repl): whatever FCS version `Fable: 4.0.0-theta-008` is based on)

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.