You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
@abelbraaksma I marked this as "feature improvement" - it should probably be "by design" since I don't think we count #if as a directive in this context. I'd need to check the language of the spec - but in any case we'd just adjust the language of the spec to clarify exactly which directives are/aren't taken into account where
@dsyme, I checked the language spec, this is what we say:
Compiler directives:
Conditional compilation, called lexical preprocessing directives
Line directives
Lightweight syntax (no name in the spec for it)
So, each is called directives (except for lightweight syntax).
Wouldn't the easiest fix be to simply improve the text? Since this error is raised in only one place, it would help by just changing it to:
FS0236 "Compiler directive '#nowarn' is ignored inside modules."
I know there's an ongoing effort in improving error messages, this could be a candidate ;). And since this error is never raised for any of the other directives, this is a safe change.
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:
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.
The text was updated successfully, but these errors were encountered: