-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Duplicated named arguments are ignored, but not rejected #4282
Comments
That's just an implementation artifact and I think we could add validation. |
Do you know what behavior you're expecting here? I started playing around with this idea a little bit and can get it to throw an exception at runtime if two named args have the same name. It doesn't seem like it can be caught at compile time without using static named args. Is that the expectation? |
Duplicate should give an exception. |
At the moment, I can verify the following: fmt::print("{bar}", "bar"_a=42, "bar"_a=43); // Fails to compile due to duplicate args.
fmt::print("{bar}", fmt::args("bar", 42), fmt::args("bar", 43)); // Throws exception at runtime due to duplicate args. What might be helpful is some direction on the static compiled strings because the following still shows the existing behavior with my changes: fmt::print(FMT_COMPILE("{bar}"), "bar"_a=42, "bar"_a=43); // Compiles and outputs `42`. I'm assuming if we can stop compile for the non-type template parameters, it should also work for compiled format strings? Edit: |
Hi,
Is example like:
This prints: "42 43"
Or this example:
This prints: "42"
Is this semantics like this by design or did it happen by mistake?
The text was updated successfully, but these errors were encountered: