diff --git a/gitlab-pages/docs/language-basics/functions.md b/gitlab-pages/docs/language-basics/functions.md
index 18173b545..5d34a5e74 100644
--- a/gitlab-pages/docs/language-basics/functions.md
+++ b/gitlab-pages/docs/language-basics/functions.md
@@ -307,7 +307,7 @@ At the moment, recursive function are limited to one (possibly tupled) parameter
limited to tail recursion (i.e the recursive call should be the last expression of the function)
-In PascaLigo recursive functions are defined using the "recursive" keyword
+In PascaLigo recursive functions are defined using the `recursive` keyword
```pascaligo group=d
recursive function sum (const n : int; const acc: int) : int is
@@ -318,7 +318,7 @@ recursive function fibo (const n: int; const n_1: int; const n_0 :int) : int is
```
-In CameLigo recursive functions are defined using the "rec" keyword
+In CameLigo recursive functions are defined using the `rec` keyword
```cameligo group=d
let rec sum ((n,acc):int * int) : int =
@@ -329,7 +329,7 @@ let rec fibo ((n,n_1,n_0):int*int*int) : int =
```
-In ReasonLigo recursive functions are defined using the "rec" keyword
+In ReasonLigo recursive functions are defined using the `rec` keyword
```reasonligo group=d
let rec sum = ((n, acc) : (int,int)): int =>
diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml
index fa87cbf15..a0c051f28 100644
--- a/src/passes/2-simplify/pascaligo.ml
+++ b/src/passes/2-simplify/pascaligo.ml
@@ -184,17 +184,6 @@ module Errors = struct
] in
error ~data title message
- let _untyped_recursive_function var =
- let title () = "" in
- let message () =
- Format.asprintf "\nUntyped recursive function \
- are not supported yet.\n" in
- let param_loc = var.Region.region in
- let data = [
- ("location",
- fun () -> Format.asprintf "%a" Location.pp_lift @@ param_loc)]
- in error ~data title message
-
(* Logging *)
let simplifying_instruction t =
@@ -751,26 +740,24 @@ and simpl_fun_expression :
let statements = [] in
(match param.value.inside with
a, [] -> (
- let%bind input = simpl_param a in
- let (binder , input_type) = input in
- let%bind instructions = simpl_statement_list statements in
- let%bind result = simpl_expression return in
- let%bind output_type = simpl_type_expression ret_type in
- let body = instructions in
- let%bind result =
- let aux prec cur = cur (Some prec) in
- bind_fold_right_list aux result body in
- let binder = Var.of_name binder in
- let fun_type = t_function input_type output_type in
- let expression : expression =
- e_lambda ~loc binder (Some input_type)(Some output_type) result in
- let%bind expression = match kwd_recursive with
- None -> ok @@ expression |
- Some _ -> ok @@ e_recursive ~loc binder fun_type
- @@ {binder;input_type=Some input_type; output_type= Some output_type; result}
- in
- ok (Some fun_type , expression)
- )
+ let%bind input = simpl_param a in
+ let (binder , input_type) = input in
+ let%bind instructions = simpl_statement_list statements in
+ let%bind result = simpl_expression return in
+ let%bind output_type = simpl_type_expression ret_type in
+ let body = instructions in
+ let%bind result =
+ let aux prec cur = cur (Some prec) in
+ bind_fold_right_list aux result body in
+ let binder = Var.of_name binder in
+ let fun_type = t_function input_type output_type in
+ let expression = match kwd_recursive with
+ | None -> e_lambda ~loc binder (Some input_type)(Some output_type) result
+ | Some _ -> e_recursive ~loc binder fun_type
+ @@ {binder;input_type=Some input_type; output_type= Some output_type; result}
+ in
+ ok (Some fun_type , expression)
+ )
| lst -> (
let lst = npseq_to_list lst in
(* TODO wrong, should be fresh? *)
@@ -795,11 +782,9 @@ and simpl_fun_expression :
let aux prec cur = cur (Some prec) in
bind_fold_right_list aux result body in
let fun_type = t_function input_type output_type in
- let expression : expression =
- e_lambda ~loc binder (Some input_type)(Some output_type) result in
- let%bind expression = match kwd_recursive with
- None -> ok @@ expression |
- Some _ -> ok @@ e_recursive ~loc binder fun_type
+ let expression = match kwd_recursive with
+ | None -> e_lambda ~loc binder (Some input_type)(Some output_type) result
+ | Some _ -> e_recursive ~loc binder fun_type
@@ {binder;input_type=Some input_type; output_type= Some output_type; result}
in
ok (Some fun_type , expression)
diff --git a/src/passes/5-self_ast_typed/tail_recursion.ml b/src/passes/5-self_ast_typed/tail_recursion.ml
index 5d22d6104..3e971c79e 100644
--- a/src/passes/5-self_ast_typed/tail_recursion.ml
+++ b/src/passes/5-self_ast_typed/tail_recursion.ml
@@ -3,7 +3,7 @@ open Trace
module Errors = struct
let recursive_call_is_only_allowed_as_the_last_operation name loc () =
- let title = (thunk ("Recursive call is only allowed as the last operation")) in
+ let title = (thunk ("Recursion must be achieved through tail-calls only")) in
let message () = "" in
let data = [
("function" , fun () -> Format.asprintf "%a" PP.expression_variable name);