Have you setup that file to be compiled with dune? Something like this from Quickstart — Dune documentation
(executable
(name test))
The 'a -> 'b
suggests it might not be compiled yet. Alternatively try explicitly adding the types like so:
let square (x : int) : int = x * x;;
square 50;;
Are there any messages in the VSCode log files? The LSP server has a logging buffer, try entering this command.
Could you provide a screenshot that actually shows the error panel and the bottom status bar ?
OCaml-LSP should be able to infer the type of square
without any additional setup.