Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #522
When encountering a named argument in a call, sem semchecks its value and passes it along with the name to sigmatch. It is also tracked if a named argument was given, in which case the arguments are reordered before passing to the
sigmatch
proc.The way the reordering is done: The signature params are iterated over first to build a table of names to param positions etc. Then the given arguments are iterated over, saving the positions of arguments belonging to each parameter. Then a new list of arguments is built in the order of the parameters. Varargs is considered by saving arguments as "continued", i.e. the parameter position is not advanced for them when building the list. Missing parameters add a dot token to mark a default value, but this does not fail early to behave the same as missing default values in normal matching.
A quirk of original Nim is that positional arguments are not influenced by named arguments before them, i.e. in
foo(name1 = val1, name2 = val2, val3, ...)
,val3
always matches the 3rd parameter of the proc. This behavior is preserved here.