summaryrefslogtreecommitdiff
path: root/compiler/PrePasses.ml
diff options
context:
space:
mode:
authorSon Ho2024-03-29 11:31:47 +0100
committerSon Ho2024-03-29 11:31:47 +0100
commit6f4833f84dd3ec17311b5e6ca9f5c1ad94ff7564 (patch)
tree630b4ec048005180e2651a56ef9b890fc6c33069 /compiler/PrePasses.ml
parentc2069900aa534d49b6c07eea8f5ab2fb70a26aa2 (diff)
Improve the error messages
Diffstat (limited to '')
-rw-r--r--compiler/PrePasses.ml19
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler/PrePasses.ml b/compiler/PrePasses.ml
index 42857a88..8c346a8c 100644
--- a/compiler/PrePasses.ml
+++ b/compiler/PrePasses.ml
@@ -214,14 +214,17 @@ let remove_loop_breaks (crate : crate) (f : fun_decl) : fun_decl =
object
inherit [_] map_statement as super
- method! visit_Loop entered_loop loop =
- cassert (not entered_loop) st.meta
- "Nested loops are not supported yet";
- super#visit_Loop true loop
-
- method! visit_Break _ i =
- cassert (i = 0) st.meta "Breaks to outer loops are not supported yet";
- nst.content
+ method! visit_statement entered_loop st =
+ match st.content with
+ | Loop loop ->
+ cassert (not entered_loop) st.meta
+ "Nested loops are not supported yet";
+ { st with content = super#visit_Loop true loop }
+ | Break i ->
+ cassert (i = 0) st.meta
+ "Breaks to outer loops are not supported yet";
+ { st with content = nst.content }
+ | _ -> super#visit_statement entered_loop st
end
in
obj#visit_statement false st