Right now, if a user passes the wrong number of arguments, one of two things can happen:
Too few arguments provided: a somewhat confusing BoundsError without context.
Too many arguments provided: the remaining ones will be ignored, which can cause a ton of subtle issues.
This is what I came up with:
In addition to showing the BoundsError, it also gives the error below.
"""
@rec: [tupleassign] Wrong number of arguments passed in tail-recursive calls
(Tuple8...) = (Tuple7...)
(a, b, c, d, e, f, g, h) = (1, 2, 3, 4, 5, 6, 7)
"""
I didn't want to break backwards compatibility, because some people might actually use this feature. This will still work, but it will give a (hopefully) helpful warning explaining what is going on and that this is probably a bad idea.
@warn """
@rec: [tupleassign] Extra arguments passed in recursive calls will be ignored
> `Lazy.@rec` keeps track of arguments in a tuple, and your recursive
> call passed extra arguments to the function. This will result (after
> macro expansion) in a snippet like `(arg1, arg2) = (rec1, rec2, rec3)`
> Julia allows you to do this (`rec3` will be ignored), but in this case
> it is most likely a mistake.
"""
It took me forever to figure out what was going on when I made this mistake, and so hopefully this can help out.
Note: The warning bit does require the Logging dependency:
Right now, if a user passes the wrong number of arguments, one of two things can happen:
This is what I came up with:
It took me forever to figure out what was going on when I made this mistake, and so hopefully this can help out.
Note: The warning bit does require the
Logging
dependency: