Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@mtkmodel: Positional arguments passed as keyword arguments #3018

Open
baggepinnen opened this issue Sep 5, 2024 · 1 comment
Open

@mtkmodel: Positional arguments passed as keyword arguments #3018

baggepinnen opened this issue Sep 5, 2024 · 1 comment
Labels
bug Something isn't working usability

Comments

@baggepinnen
Copy link
Contributor

baggepinnen commented Sep 5, 2024

The following instantiation of a component

        @components begin
            filter = DiscreteTransferFunction(G; z)
        end

calls DiscreteTransferFunction(; G, z), i.e., G is passed as a keyword argument despite the fact that it was indicated to be a positional argument. Not being able to use positional arguments is very limiting, it means that there can only be a single method for any component constructor, and component constructors that use positional arguments cannot be called in a model defined by @mtkmodel.

@macroexpand indicates that the keyword-arg separator ; is put in the right place, but the name of the positional arg is mistakenly included:

DiscreteTransferFunction(G = _filter__G; name = :filter,
@baggepinnen baggepinnen added the bug Something isn't working label Sep 5, 2024
@baggepinnen
Copy link
Contributor Author

The offending code is

        MLStyle.@match arg begin
            x::Symbol || Expr(:kw, x) => begin

which matches and does the same thing for arg being either Symbol or a :kw expression. These have to be two separate cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working usability
Projects
None yet
Development

No branches or pull requests

1 participant