Skip to content

Unexpected matches in @capture of function definition #120

@omalled

Description

@omalled

I ran into some unexpected matching behavior in a function definition (see below). I'm not sure if this should be a match or not. However, if it is a match it seems to by swapping xsym and args (e.g., I would expect xsym to get :x rather than args getting that). I'm guessing this can be worked around by using some of the function definition documentation?

julia> @MacroTools.capture(:(function f(x; n=100) return 1 end), function funsym_(xsym_, args__) body_ end)
true

julia> xsym
:($(Expr(:parameters, :(n=100))))

julia> args
1-element Array{Any,1}:
 :x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions