FluxML / FluxML/MacroTools.jl

Unexpected matches in @capture of function definition

Open
#120 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
320
Forks
84
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @MacroTools.capture entry point and the linked function-definition documentation, then reproduce the Julia example exactly. Compare the bindings assigned to xsym and args with the documented matching semantics; done means the intended behavior is established and the example is corrected or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.