-
Notifications
You must be signed in to change notification settings - Fork 825
Open
Labels
Area-Diagnosticsmistakes and possible improvements to diagnosticsmistakes and possible improvements to diagnosticsFeature Request
Milestone
Description
When defining a type using light syntax (it doesn't matter what kind of type: class, interface, union, record), it is possible to define what appears to be a nested module (at the same indentation level as the rest of the contents of the type), but what actually results in a module defined in the same scope as the type.
type IFace =
abstract F : int -> int
module M =
let f () = ()
type C () =
member _.F () = 3
module M2 =
let f () = ()
type U =
| A
| B
module M3 =
let f () = ()
type R =
{ A : int }
module M4 =
let f () = ()
// Etc.
// All modules M, M2, M3, M4 are in scope here.
Using verbose syntax disallows this, as expected.
type IFace =
interface
abstract F : int -> int
module M = // FS0010: Unexpected keyword 'module' in type definition. Expected 'end' or other token.
let f () = f ()
end
// Etc.
Expected behavior
A module nested inside of a type shouldn't compile, or some kind of indentation warning should be given.
Actual behavior
The module is compiled in the same scope as the type.
Known workarounds
Don't confusingly misindent your module definition.
Metadata
Metadata
Assignees
Labels
Area-Diagnosticsmistakes and possible improvements to diagnosticsmistakes and possible improvements to diagnosticsFeature Request
Type
Projects
Status
New