FSI version: 11.0.50727.1
So I was working on an F# shell script and I ran across something that sort of surprised me.
When I did this:
#if INTERACTIVE
#r "System.Data.dll"
#r "FSharp.Data.TypeProviders.dll"
#r "System.Data.Linq.dll"
#endif
open System
I got an FS0010 error when I pasted the block into the FSI. But if I did not indent the #r lines, no FS0010 error. I’m just sort of surprised that preprocessor lines would be indentation sensitive. Is this a compiler issue or is there something else at work here?
I think the specification and documentation are quite unclear on this topic, but the specification makes a notable distinction between lexical preprocessor directives and compiler directives (see §12.4):
My interpretation is that lexical preprocessor directives are actually hanled by some pre-processor before running the main compilation and so the indentation does not matter for these.
On the other hand, directives like
#r,#load,#timeetc. are processed later by the compiler and so they need to match the usual F# indentation guidelines.As @unwind says, the documentation states "Indentation is not significant for preprocessor directives", but I think this applies only to the preprocessor directives listed on that documentation page (which are lexical preprocessor directives and not compiler directives).