'F# error FS0588: The block following this 'let' is unfinished. Every code block is an expression and must have a result

I am tasked with finishing an interpreter in F#, but I'm having some trouble, as I im getting the error: error FS0588: 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.

Its been a long time since last time I programmed I F#.

The following is my code. I have a helper function inside my eval function, called OperateAux. It gets called in the pattern matching, when it matches e with OPERATE. It should then call OperateAux, and calculate the given expression. The error I'm getting is at line: let OperateAux (op:BINOP) (e1:EXP) (e2:EXP) : VALUE = so I guess somehow my helper function isn't finished, I just cant figure out where.

let rec eval (vtab : SymTab) (e : EXP) : VALUE =
  match e with
    | CONSTANT n -> n
    | VARIABLE v -> lookup v vtab 
    | OPERATE (op, e1, e2) -> OperateAux op e1 e2//(eval vtab e1) (eval vtab e2) 
    | LET_IN (var, e1, e2) -> failwith "case for LET_IN not handled"
    | OVER (rop, var, e1, e2, e3) -> failwith "case for OVER not handled"

  let OperateAux (op:BINOP) (e1:EXP) (e2:EXP) : VALUE = 
    let (INT e1) = eval vtab e1
    let (INT e2) = eval vtab e2 
    match op with 
      | BPLUS -> (e1+e2) 
      | BMINUS  -> (e1-e2)
      | BTIMES -> (e1*e2)
      | _ -> ()

Here is some types, I'm not sure if they are relevant for this question, but for good measure I'll show them.

type VALUE = INT of int

type BINOP = BPLUS | BMINUS | BTIMES

type RANGEOP = RSUM | RPROD | RMAX | RARGMAX

type EXP =
  | CONSTANT  of VALUE
  | VARIABLE  of string
  | OPERATE   of BINOP * EXP * EXP
  | LET_IN    of string * EXP * EXP
  | OVER      of RANGEOP * string * EXP * EXP * EXP

(* A list mapping variable names to their values. *)
type SymTab = (string * VALUE) list


Solution 1:[1]

Nevermind, I figured it out. You have to "initialise" your helper function before actually calling it. So the helper function operateAux should come before the pattern matching which calls it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ninjarubberband