2020-06-12 13:33:14 +02:00
|
|
|
open Errors
|
2020-03-12 23:20:39 +01:00
|
|
|
open Ast_imperative
|
2020-02-21 17:07:48 +01:00
|
|
|
open Trace
|
|
|
|
open Stage_common.Helpers
|
|
|
|
|
2020-06-12 13:33:14 +02:00
|
|
|
let peephole_type_expression : type_expression -> (type_expression , self_ast_imperative_error) result = fun e ->
|
2020-04-09 18:19:22 +02:00
|
|
|
let return type_content = ok {type_content; location=e.location } in
|
2020-02-21 17:07:48 +01:00
|
|
|
match e.type_content with
|
|
|
|
| T_sum cmap ->
|
|
|
|
let%bind _uu = bind_map_cmapi
|
|
|
|
(fun k _ ->
|
|
|
|
let (Constructor name) = k in
|
2020-06-12 13:33:14 +02:00
|
|
|
if (String.length name >= 32) then fail @@ too_long_constructor name e
|
2020-02-21 17:07:48 +01:00
|
|
|
else ok ()
|
|
|
|
)
|
|
|
|
cmap in
|
|
|
|
ok e
|
|
|
|
| e -> return e
|