No indentation warning is given when a hash directive is used inside a nested module
Consider File.fsx:
// implicit top-level module File
let x = 42
module Nested =
// File.Nested.foo
let foo = 123
#load "OtherFile.fsx"
// Looks like File.Nested.bar, but is actually File.bar due to the use of #load.
// Unlike conditional hash directives it terminates declarations/expressions,
// which may be not very obvious to users.
// I suppose, being in the outer module it should have the same indentation
// as x and Nested module, however no indentation warning/error is given.
// Looks like it also adds another context in the LexFilter,
// which in turn makes next expressions indented incorrectly.
let bar = foo // foo is unresolved
let y = x // incorrect indentation
Related to (but not the same) #3486 and #3487.
I think that indentation is ignored because # lines are typically a type of compiler directive and as such not part of the indentation rules. My guess is, this is by design.
I think is just a bug:
The compiler is fine with:
module Nested =
// File.Nested.foo
let foo = 123
#if SOMEDIRECTIVE
#endif
// looks like File.Nested.bar, but is actually File.bar
// No indentation warning given and foo is unresolved
let bar = foo
We probably just need to make sure that FSI only directives work correctly here.
@auduchinok, my apologies, I misunderstood, as I focused on the text and title and missed the comments in the code.
Could you perhaps update the original text with a complete repro (this module is currently not nested) and explain the issue in the text to forego such misunderstandings?
@abelbraaksma I've updated the code repro and added more clarification in the comments there.