From 03b8bd8ac5631e0edf32f61c06262b935ae9ff56 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Tue, 2 Dec 2025 08:02:06 +0100 Subject: [PATCH] try to handle stack overflow in linter due to autovec --- lib/ControlSystemsBase/src/freqresp.jl | 4 ++-- lib/ControlSystemsBase/src/utilities.jl | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ControlSystemsBase/src/freqresp.jl b/lib/ControlSystemsBase/src/freqresp.jl index b923e57fd..0206e1074 100644 --- a/lib/ControlSystemsBase/src/freqresp.jl +++ b/lib/ControlSystemsBase/src/freqresp.jl @@ -463,7 +463,7 @@ sys = ss([-1 0; 0 -2], [1 0; 0 1], [1 1; 0 1], 0) sv, w = sigma(sys) ``` """ -@autovec (1) function sigma(sys::LTISystem, w::AbstractVector) +@autovec (1,) function sigma(sys::LTISystem, w::AbstractVector) resp = freqresp(sys, w) ny, nu = size(sys) if ny == 1 || nu == 1 # Shortcut available @@ -476,7 +476,7 @@ sv, w = sigma(sys) end return sv, w end -@autovec (1) sigma(sys::LTISystem) = sigma(sys, _default_freq_vector(sys, Val{:sigma}())) +@autovec (1,) sigma(sys::LTISystem) = sigma(sys, _default_freq_vector(sys, Val{:sigma}())) function _default_freq_vector(systems::Vector{<:LTISystem}, plot; adaptive=false) if adaptive diff --git a/lib/ControlSystemsBase/src/utilities.jl b/lib/ControlSystemsBase/src/utilities.jl index c04c43387..b38912eb1 100644 --- a/lib/ControlSystemsBase/src/utilities.jl +++ b/lib/ControlSystemsBase/src/utilities.jl @@ -155,10 +155,11 @@ the output tuple should be flattened. If the function only has a single output i (not a tuple with a single item) it should be called as `@autovec () f() = ...`. `f()` is the original function and `fv()` will be the version with flattened outputs. """ -macro autovec(indices, f) +macro autovec(indices0, f) dict = MacroTools.splitdef(f) rtype = get(dict, :rtype, :Any) - indices = eval(indices) + MacroTools.@capture indices0 (inds__,) + indices = inds # If indices is empty it means we vec the entire return value if length(indices) == 0