Emit an error message when an unsupported OutputType is specified
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
_Title edited by @cartermp to reflect the assessment of the issue_
It looks like the F# compiler generates incorrect code for certain projects with `dll`. For the modules of the last file the *let-bound values* are not initialized because the initialization code is not in the static constructor of the generated class but in a custom method `main@` that never gets called.
**Repro steps**
1. Download the [repro](https://github.com/dotnet/fsharp/files/4712179/FSharpInitializeBug.zip)
1. Run `dotnet run -p app
**Expected behavior**
Output should be something like
```
Number: 3
```
**Actual behavior**
Output is
```
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Program.main(String[] argv) in C:\Users\egger\Workspace\FSharpInitializeBug\app\Program.fs:line 3
```
**Known workarounds**
* Remove `dll` in `lib/Test.Lib.fsproj`
* Don't use `Library.fs` as the last file of the project.
**Related information**
```
> dotnet --version
3.1.300
```
Contributor guide
Assessment
This issue has not been assessed yet.