Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment the next arg id on named arguments to allow adding positional arguments after named arguments. #3819

Closed
wants to merge 2 commits into from

Conversation

calebkiage
Copy link

@calebkiage calebkiage commented Jan 19, 2024

Increment the next arg id on named arguments to allow adding positional arguments after named arguments.

Closes #3817

@calebkiage calebkiage changed the title Fix issue #3817 Increment the next arg id on named arguments to allow adding positional arguments after named arguments. Jan 19, 2024
@vitaut
Copy link
Contributor

vitaut commented Jan 20, 2024

Fixed in 4c5b4af but thanks for the PR.

@vitaut vitaut closed this Jan 20, 2024
@calebkiage
Copy link
Author

This PR handles the case instead of throwing an exception. Isn't that a better developer experience?

@calebkiage
Copy link
Author

calebkiage commented Jan 20, 2024

I thought this intuition could be used for the arguments: if an automatic arg is used, advance the next argument, if a manual is used, set the next argument index. That way, they can be mixed together.

@vitaut
Copy link
Contributor

vitaut commented Jan 20, 2024

Named arguments are conceptually similar to positional ones. Mixing them with automatic indexing is very confusing which is why it is better to ban them as we already do elsewhere.

@calebkiage
Copy link
Author

That's fair enough. What I've seen other libraries do to mix them is to give the behavior of a moving index that is reset by manual indexing. So, format("{} {} {0} {}") is the same as format("{0} {1} {0} {1}").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The vformat & vprint functions produce incorrect output when mixing named and positional arguments.
2 participants