Skip to content

Commit 5e9be23

Browse files
committed
Give explicit error message for ast cases not implemented.
1 parent eb1963f commit 5e9be23

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# master
2+
- Give explicit error message for ast cases not implemented.
23

34
# 2.16.0
45
- Limited support for project with dune namespaces: when `Mylib.Foo` is not found try `Foo`.

src/Arnold.ml

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,10 @@ module Compile = struct
689689
let rec expression ~ctx (expr : Typedtree.expression) =
690690
let {currentFunctionName; functionTable; isProgressFunction} = ctx in
691691
let loc = expr.exp_loc in
692+
let notImplemented case =
693+
Log_.error ~loc ~name:"Error Not Implemented" (fun ppf () ->
694+
Format.fprintf ppf case)
695+
in
692696
match expr.exp_desc with
693697
| Texp_ident _ -> Command.nothing
694698
| Texp_apply
@@ -911,22 +915,51 @@ module Compile = struct
911915
let open Command in
912916
cE +++ cCases
913917
| Texp_variant (_label, eOpt) -> eOpt |> expressionOpt ~ctx
914-
| Texp_while _ -> assert false
915-
| Texp_for _ -> assert false
916-
| Texp_send _ -> assert false
917-
| Texp_new _ -> assert false
918-
| Texp_instvar _ -> assert false
919-
| Texp_setinstvar _ -> assert false
920-
| Texp_override _ -> assert false
921-
| Texp_letmodule _ -> assert false
922-
| Texp_letexception _ -> assert false
923-
| Texp_lazy _ -> assert false
924-
| Texp_object _ -> assert false
925-
| Texp_pack _ -> assert false
926-
| Texp_unreachable -> assert false
927-
| Texp_extension_constructor _ when true -> assert false
918+
| Texp_while _ ->
919+
notImplemented "Texp_while";
920+
assert false
921+
| Texp_for _ ->
922+
notImplemented "Texp_for";
923+
assert false
924+
| Texp_send _ ->
925+
notImplemented "Texp_send";
926+
assert false
927+
| Texp_new _ ->
928+
notImplemented "Texp_new";
929+
assert false
930+
| Texp_instvar _ ->
931+
notImplemented "Texp_instvar";
932+
assert false
933+
| Texp_setinstvar _ ->
934+
notImplemented "Texp_setinstvar";
935+
assert false
936+
| Texp_override _ ->
937+
notImplemented "Texp_override";
938+
assert false
939+
| Texp_letmodule _ ->
940+
notImplemented "Texp_letmodule";
941+
assert false
942+
| Texp_letexception _ ->
943+
notImplemented "Texp_letexception";
944+
assert false
945+
| Texp_lazy _ ->
946+
notImplemented "Texp_lazy";
947+
assert false
948+
| Texp_object _ ->
949+
notImplemented "Texp_letmodule";
950+
assert false
951+
| Texp_pack _ ->
952+
notImplemented "Texp_pack";
953+
assert false
954+
| Texp_unreachable ->
955+
notImplemented "Texp_unreachable";
956+
assert false
957+
| Texp_extension_constructor _ when true ->
958+
notImplemented "Texp_extension_constructor";
959+
assert false
928960
| _ ->
929961
(* ocaml 4.08: Texp_letop(_) | Texp_open(_) *)
962+
notImplemented "Texp_letop(_) | Texp_open(_)";
930963
assert false
931964

932965
and expressionOpt ~ctx eOpt =

0 commit comments

Comments
 (0)