Skip to content

FMT_COMPILE is inconsistent compared to without #4419

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

Closed
teksturi opened this issue Apr 17, 2025 · 2 comments
Closed

FMT_COMPILE is inconsistent compared to without #4419

teksturi opened this issue Apr 17, 2025 · 2 comments
Labels

Comments

@teksturi
Copy link

teksturi commented Apr 17, 2025

I found out that these will throw and are not even catched compile time.

fmt::print("{a0}{}", fmt::arg("a0", "bug?"));
fmt::print("{a0}{}", fmt::arg("a0", "foo"), "bug?"));

Strange thing is that if we use FMT_COMPILE these work just fine

fmt::print(FMT_COMPILE("{a0}{}"), fmt::arg("a0", "foo"));
fmt::print(FMT_COMPILE("{a0}{}"), fmt::arg("a0", "foo"), "faa"));

I however would say that if there is named argument and after that there is automatic argument it would always be compile time error. Same way as index based.

I also found that this can be run

fmt::print(FMT_COMPILE("{n}"), fmt::arg("n", "bug?"), fmt::arg("n", 3));

but without FMT_COMPILE it will throw at runtime "duplicate named arg".

I would also like to know what is intended functionality so maybe some one can try to fix this issue. Also is intention that FMT_COMPILE will always work same way as without?

@teksturi
Copy link
Author

The second case is probably same as in here #4124

@vitaut
Copy link
Contributor

vitaut commented Apr 18, 2025

The second case is probably same as in here #4124

Yes and the first case is expected. Compile-time checks for named arguments require UDLs (_a).

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

No branches or pull requests

2 participants