Skip to content

FS0236 "Directives inside modules are ignored" is incomplete and gives the wrong impression, directives inside modules are often allowed #3486

Open
@abelbraaksma

Description

@abelbraaksma

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:

image

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.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions