FluxML / MacroTools.jl

MacroTools provides a library of tools for working with Julia code and expressions.
https://fluxml.ai/MacroTools.jl/stable/
Other
310 stars 79 forks source link

Wrong slurp flag for slurps with default args #165

Closed untoreh closed 2 years ago

untoreh commented 3 years ago
## Passes
args = splitdef(Meta.parse("f(v::Int...) = v"))[:args]
spa = splitarg(args[1])
@assert spa[3] == true 
@assert spa[4] == nothing

## Slurp fails
args = splitdef(Meta.parse("f(v::Int...=0) = v"))[:args]
spa = splitarg(args[1])
@assert spa[3] == true # This one fails, should be true
@assert spa[4] == 0
cstjean commented 3 years ago

I don't get it. What behaviour did you expect?

untoreh commented 3 years ago

the third assertion should pass, v is a slurp argument with a default value, so the third element of the tuple returned by splitarg should return true since it is the slurp flag (name, type, SLURP, default)

cstjean commented 3 years ago

Oh, ok, thanks for the edit. I agree, something's wrong here. PR welcome.