summaryrefslogtreecommitdiff
path: root/compiler/PureUtils.ml
diff options
context:
space:
mode:
authorSon Ho2022-12-14 18:25:49 +0100
committerSon HO2023-02-03 11:21:46 +0100
commit20332f3faa5e1205602c946f1c7abb9b6660e6f0 (patch)
tree4ac5f36f0487a53f6461885fd25c70c06b6f656c /compiler/PureUtils.ml
parent1a912cbf23c31c95041526c71bbd050bb5ac4e7c (diff)
Add a `Loop` node in the pure AST
Diffstat (limited to '')
-rw-r--r--compiler/PureUtils.ml6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/PureUtils.ml b/compiler/PureUtils.ml
index da15d635..0e245f35 100644
--- a/compiler/PureUtils.ml
+++ b/compiler/PureUtils.ml
@@ -113,6 +113,9 @@ let fun_sig_substitute (tsubst : TypeVarId.id -> ty) (sg : fun_sig) :
(** We use this to check whether we need to add parentheses around expressions.
We only look for outer monadic let-bindings.
This is used when printing the branches of [if ... then ... else ...].
+
+ Rem.: this function will *fail* if there are {!Loop} nodes (you should call
+ it on an expression where those nodes have been eliminated).
*)
let rec let_group_requires_parentheses (e : texpression) : bool =
match e.e with
@@ -121,6 +124,9 @@ let rec let_group_requires_parentheses (e : texpression) : bool =
if monadic then true else let_group_requires_parentheses next_e
| Switch (_, _) -> false
| Meta (_, next_e) -> let_group_requires_parentheses next_e
+ | Loop _ ->
+ (* Should have been eliminated *)
+ raise (Failure "Unreachable")
let is_var (e : texpression) : bool =
match e.e with Var _ -> true | _ -> false