From dd0a2d9cef9d70ddb6d25448b8241e259c950420 Mon Sep 17 00:00:00 2001 From: Daniel Larraz Date: Wed, 28 Aug 2024 16:22:05 -0500 Subject: [PATCH] Fix dependency analysis for polymorphic user types --- src/lustre/lustreAstDependencies.ml | 5 ++++- tests/regression/success/poly_user_type.lus | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/regression/success/poly_user_type.lus diff --git a/src/lustre/lustreAstDependencies.ml b/src/lustre/lustreAstDependencies.ml index 59e3fa92b..7a81990be 100644 --- a/src/lustre/lustreAstDependencies.ml +++ b/src/lustre/lustreAstDependencies.ml @@ -291,7 +291,10 @@ let rec mk_graph_type: LA.lustre_type -> dependency_analysis_data = function | Some e2 -> mk_graph_expr e2 in union_dependency_analysis_data g1 g2 - | UserType (pos, _, i) -> singleton_dependency_analysis_data ty_prefix i pos + | UserType (pos, ty_args, i) -> ( + let usr_g = singleton_dependency_analysis_data ty_prefix i pos in + List.fold_left union_dependency_analysis_data usr_g (List.map mk_graph_type ty_args) + ) | AbstractType (pos, i) -> singleton_dependency_analysis_data ty_prefix i pos | TupleType (_, tys) -> List.fold_left union_dependency_analysis_data empty_dependency_analysis_data (List.map (fun t -> mk_graph_type t) tys) | GroupType (_, tys) -> List.fold_left union_dependency_analysis_data empty_dependency_analysis_data (List.map (fun t -> mk_graph_type t) tys) diff --git a/tests/regression/success/poly_user_type.lus b/tests/regression/success/poly_user_type.lus new file mode 100644 index 000000000..ff8741ac0 --- /dev/null +++ b/tests/regression/success/poly_user_type.lus @@ -0,0 +1,18 @@ +type R0<> = struct { + v: T; +}; + +type E = enum {A, B}; + +type R1 = struct { + f: E; +}; + +type R2 = struct { + opt: R0<>; +}; + +node N(x: R2) returns (y: R2); +let + y = x; +tel \ No newline at end of file