Reputation: 12107
I have the following line:
| ResponseTableTypes.Order ->
orderProcessor.ProcessEvent action message
orderEvent.Trigger()
since I have a lot of entries, for layout reasons, I did:
| ResponseTableTypes.Order -> orderProcessor.ProcessEvent action message; orderEvent.Trigger()
all good, but then I added some return type:
| ResponseTableTypes.Order -> let s = orderProcessor.ProcessEvent action message; orderEvent.Trigger(s)
that will not compile, I get:
The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result.
so, if I break down the line again:
| ResponseTableTypes.Order ->
let s = orderProcessor.ProcessEvent action message
orderEvent.Trigger(s)
then it obviously works again
what is happening with the let/semicolon combination?
Upvotes: 0
Views: 284
Reputation:
Starting with | ResponseTableTypes.Order -> let s = orderProcessor.ProcessEvent action message; orderEvent.Trigger(s)
, let's reduce irrelevancies such as tables, orders, and events:
let result =
let s = expression; action
Now let's ascribe simple values to the names, so that apart from the issue we want to identify, it should compile.
let x =
let y = 0; 0
// FS0588 the block following this let is unfinished.
// FS0020 The result of this expression has type 'int' and is implicitly ignored.
Now that we have a clean question, we can start to answer it, but this is the easy part. let y = 0; 0
is equivalent to let y = (0;0)
and so the first 0
is being ignored, and since let y = ...
is an incomplete expression which does not return anything, there is nothing to ascribe to x
.
There is an antique syntax let y = 0 in 0
which does allow merging multiple lines with let
s into one.
Upvotes: 3