FS0236 "Directives inside modules are ignored" is incomplete and gives the wrong impression, directives inside modules are often allowed
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
When you use a compiler directive, specifically `#nowarn`, inside a module, the message is "Directives inside modules are ignored". This message is incomplete and it takes some experimenting to find out its statement is usually not true.
## Repro steps
Take the following code:
```
module XBar =
#nowarn "test"
#if FALSE
module other =
let x = 12
#endif
```
This will show a warning for the first directive, but not the second:

## Expected behavior
The warning should be more specific, I think it essentially only applies to `#nowarn` directives?
## Actual behavior
Regardless of the warning, the directive `#if` is obeyed, as is `#line` and perhaps others (but `#nowarn` is not, but this is a known limitation and by design).
## Known workarounds
Just learn to not be too alarmed by this all-too-generic warning :).
## Related information
This behavior can be seen on all versions of F# and VS, at least back to VS2015 and F# 4.0.
Contributor guide
Assessment
This issue has not been assessed yet.