i have got several times , trying to implement different functions, the message you see as title. I would like to know if anyone can tell me the general meaning (and reason) of this error message. As i mentioned before, i have got the problem several times and manage to fix it, but still didnt get the exact reason, so i will not post any specific code.
Thank you in advance
The most common case when you may get this error is when you write let
binding that is not followed by an expression that calculates the result. In F#, everything is an expression that returns some result, so if you write let a = 10
it is generally not a valid expression. To make it valid, you need to return something:
let foo () =
let a = 10
() // return unit value (which doesn't represent any information)
The only exception where you can write just let a = 10
is a global scope of an F# source file - for example, inside a module declaration or in an F# script file. (This is why the declaration of foo
above is valid).
It is difficult to give any advice without seeing your code, but you probably have a let
declaration that is not followed by an F# expression.
Out of curiosity, the following example shows that let
can really be used inside an expression (where it must return some meaningful result):
let a = 40 + (let a = 1
a + a)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With