From 74649e55d9ce7b098242b52cc77aba205ef46d90 Mon Sep 17 00:00:00 2001 From: Daniel Larraz Date: Fri, 6 Oct 2023 11:30:06 -0500 Subject: [PATCH] Inline constants in type of free constant --- src/lustre/lustreAstInlineConstants.ml | 4 +++- tests/regression/success/test_const_decls.lus | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lustre/lustreAstInlineConstants.ml b/src/lustre/lustreAstInlineConstants.ml index 2a57510bb..1ba975332 100644 --- a/src/lustre/lustreAstInlineConstants.ml +++ b/src/lustre/lustreAstInlineConstants.ml @@ -490,7 +490,9 @@ let substitute: TC.tc_context -> LA.declaration -> (TC.tc_context * LA.declarati | TypeDecl (span, AliasType (pos, i, t)) -> let t' = inline_constants_of_lustre_type ctx t in ctx, LA.TypeDecl (span, AliasType (pos, i, t')) - | ConstDecl (_, FreeConst _) as c -> (ctx, c) + | ConstDecl (span, FreeConst (pos, id, ty)) -> + let ty' = inline_constants_of_lustre_type ctx ty in + ctx, ConstDecl (span, FreeConst (pos, id, ty')) | ConstDecl (span, UntypedConst (pos', i, e)) -> let e' = simplify_expr ctx e in (match (TC.lookup_ty ctx i) with diff --git a/tests/regression/success/test_const_decls.lus b/tests/regression/success/test_const_decls.lus index 59192ba9b..f8bb366a5 100644 --- a/tests/regression/success/test_const_decls.lus +++ b/tests/regression/success/test_const_decls.lus @@ -63,6 +63,8 @@ type m = int^5*h; -- Free constants, must have a type (declared later) const a1, a2, a3: a; +const a4: subrange [-1,2] of int; + -- Define constants without a type, will be inferred const b01 = 1; pi = 3.14;