Improve error reporting: importing modules from an assembly compiled as Exe but without explicit EntryPoint should raise a warning
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
## what
F# users not acquainted with module static initialization semantics in exe project (which apparently differ from library project) might expect a different result when doing this:
## steps
``` shell
C:\tmp\repro>more main.fs
```
``` fsharp
module Foo
type Buildable = Buildable of obj
let o = Buildable null
```
``` shell
C:\tmp\repro>fsc main.fs
Microsoft (R) F# Compiler version 14.0.23413.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
C:\tmp\repro>more test.fsx
```
``` fsharp
#r @"main.exe"
printfn "%A" Foo.o
```
``` shell
C:\tmp\repro>fsi test.fsx
C:\tmp\repro>
```
## Actual results
The static type initializer for module Foo wasn't executed and `Foo.o` will always remain null.
## Expected results
If we want to preserve that behaviour, I think a warning when referencing a .exe containing F# modules would help user to understand that modules might not be initialized as intended.
If we could fix the behaviour while maintaining compatibility / non breaking change, that would IMHO be ideal.
Contributor guide
Assessment
This issue has not been assessed yet.