From a9c256fe95523842a1ff025e73f6e9ce7c2db38a Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 18 Aug 2023 10:44:01 +0200 Subject: Add tests which use const generics as values --- compiler/PureMicroPasses.ml | 4 ++-- compiler/PureUtils.ml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'compiler') diff --git a/compiler/PureMicroPasses.ml b/compiler/PureMicroPasses.ml index 65dc7ff2..b2f3bb9f 100644 --- a/compiler/PureMicroPasses.ml +++ b/compiler/PureMicroPasses.ml @@ -681,8 +681,8 @@ let inline_useless_var_reassignments (inline_named : bool) (inline_pure : bool) | _ -> false in (* And either: - * 2.1 the right-expression is a variable or a global *) - let var_or_global = is_var re || is_global re in + * 2.1 the right-expression is a variable, a global or a const generic var *) + let var_or_global = is_var re || is_cvar re || is_global re in (* Or: * 2.2 the right-expression is a constant value, an ADT value, * a projection or a primitive function call *and* the flag diff --git a/compiler/PureUtils.ml b/compiler/PureUtils.ml index 461098f2..f099ef9c 100644 --- a/compiler/PureUtils.ml +++ b/compiler/PureUtils.ml @@ -185,6 +185,9 @@ let is_var (e : texpression) : bool = let as_var (e : texpression) : VarId.id = match e.e with Var v -> v | _ -> raise (Failure "Unreachable") +let is_cvar (e : texpression) : bool = + match e.e with CVar _ -> true | _ -> false + let is_global (e : texpression) : bool = match e.e with Qualif { id = Global _; _ } -> true | _ -> false -- cgit v1.2.3