From 603cafdd5f683cfd45f4603ff3b64459d8faf444 Mon Sep 17 00:00:00 2001 From: Tortar <68152031+Tortar@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:53:44 +0100 Subject: [PATCH] Fix constrained parametrization for sum_structs macro (#32) --- Project.toml | 2 +- src/SumStructs.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 7f71e25..3bf31f7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "MixedStructTypes" uuid = "3d69f371-6fa5-5add-b11c-3293622cad62" -version = "0.2.4" +version = "0.2.5" [deps] ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04" diff --git a/src/SumStructs.jl b/src/SumStructs.jl index c4823cc..2f6fc86 100644 --- a/src/SumStructs.jl +++ b/src/SumStructs.jl @@ -149,7 +149,8 @@ macro sum_structs(type, struct_defs) a_spec_n_d = [d != "#328723329" ? Expr(:kw, n, d) : (:($n)) for (n, d) in zip(f_params_args, fd)] f_params_kwargs = Expr(:parameters, a_spec_n_d...) - @capture(type, new_type_n_{new_type_p__}) + new_typ = type isa Expr && type.head == :(<:) ? type.args[1] : type + @capture(new_typ, new_type_n_{new_type_p__}) if new_type_p === nothing new_type_n, new_type_p = type, [] end