Compiler warning: FS0058: Possible incorrect indentation

I wrote this code with Visual Studio but when I compile it, it gives me back these warnings:

FS0058: Possible incorrect indentation, this token is offside of context started at position 9:80. Try indenting this token further or using standard formatting .

But if I try to compile it with an OCaml compiler it works.

let converti_tempo = (fun x -> if x < 0 then failwith "error" else if x < 1000 then (0, 0, x) else 
let rec m = x % 1000
let s = (x / 1000) % 60
let mm = ((x / 1000) / 60) % 60
in (mm,s ,m ));;

At the end of the first line you have an else. This implies that the expression of the else is going to be defined on the next line and thus will have to be indented all the way to the else and then a bit more. Code below:

let converti_tempo = (fun x -> if x < 0 then failwith "error" else if x < 1000 then (0, 0, x) else 
                                                                                               let rec m = x % 1000
                                                                                               let s = (x / 1000) % 60
                                                                                               let mm = ((x / 1000) / 60) % 60
                                                                                               in (mm,s ,m ));;

You could also write it like this:

let converti_tempo = (fun x -> if x < 0 then failwith "error" 
                               else if x < 1000 then (0, 0, x) 
                               else
                                  let rec m = x % 1000
                                  let s = (x / 1000) % 60
                                  let mm = ((x / 1000) / 60) % 60
                                  in (mm,s ,m ));;

f#, I wrote this code with Visual Studio but when I compile it, it gives me back these warnings: FS0058: Possible incorrect indentation, this token is offside of context  FS0058 warning on incorrect indentation incorrectly thrown with method attributes #1649

I would say this is a more "idiomatic" way of writing this function

let converti_tempo x =
    if x < 0 then
        failwith "error" 
    elif x < 1000 then
        (0, 0, x)
    else
        let m = x % 1000
        let s = x / 1000 % 60
        let mm = x / 1000 / 60 % 60
        (mm, s, m)

Compiler warning: FS0058: Possible incorrect indentation, I wrote this code with Visual Studio but when I compile it, it gives me back these warnings: FS0058: Possible incorrect indentation, this token is offside of context  warning FS0058: Possible incorrect indentation #352. Closed warning FS0058: Possible incorrect indentation #352. vzkosov opened this issue Feb 3,

For me this compiler warning was caused by one of my "let"s not being properly aligned. Make sure all of your function declarations start at the very start of each new line.

Programming F#: A comprehensive guide for writing simple code to , This is because the compiler wouldn't be able to determine if the failwith was <​greeting> and <thing>" Warning FS0058: possible incorrect indentation: this  Program.fs(6,9): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (5:19). Try indenting this token further or using standard formatting conventions.

FS0058 warning on incorrect indentation incorrectly thrown with , No warnings in either case. Known workarounds. The workarounds are: Don't use attributes on let-bindings (may not be possible); Don't  Posted by Nikita Baldan, Jun 13, 2016 5:51 AM

FS0058 repeats for every let and member · Issue #2948 · dotnet , specific way to provoke repetitive warnings FS0058 "Possible incorrect indentation" dsyme added the Area-Compiler label on Jun 22, 2017. See: Compiler Options (F#)--nowarn:<int-list>: Disable specific warnings listed by number. Separate each warning number by a comma. You can discover the warning number for any warning from the compilation output. This compiler option is equivalent to the C# compiler option of the same name.

Mastering .NET Machine Learning, If the code was written like this: let multiplyByTwo(x) = x * 2 The compiler would complain: Script1.fsx(8,1): warning FS0058: Possible incorrect indentation: this  Ideone is something more than a pastebin; it's an online compiler and debugging tool which allows to compile and run code online in more than 40 programming languages.