should emit a compilation error that let rec bindings inside of a function definition are not allowed. It should suggest the programmer to just define an auxiliary function outside, and it can reuse the name of the let rec binding for it. For example:
We found a `let rec` binding for `f` inside of `let_rec/0` and these are not supported.
Did you mean to define a `f_aux` outside instead?
Instead it compiles to this Erlang:
let_rec() ->
F = fun (X) -> f(erlang:'+'(X, 1)) end,
F(0).
which is misleading at first, but we can tell is wrong because it is trying to recurse into the function f/1 which is in fact not defined anywhere.
The following OCaml
should emit a compilation error that
let rec
bindings inside of a function definition are not allowed. It should suggest the programmer to just define an auxiliary function outside, and it can reuse the name of the let rec binding for it. For example:Instead it compiles to this Erlang:
which is misleading at first, but we can tell is wrong because it is trying to recurse into the function
f/1
which is in fact not defined anywhere.This can be fixed in the mapping of
Texp_let
values by checking if the recursive flag is set to true and extending theOCaml_to_erlang.Error
module with the right message.Other notes
I'd like to enable this pattern in the future, as it could be done translating the expression to:
which could be standardized as part of the
caramel.erl
runtime libraries:But I fear this would not be as useful right now. We'll see later!