Skip to content

Do not discard amended format when f-interpolator warns #23697

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

Also use the same error of kind Interpolation for warnings in s.

There are assorted errors that f emits, and a handful of warnings (about format string edge cases).

Previously, f would discard the amended "parts" and adapted "args" on any diagnostic; the transform would just call format directly, so the output looks normal. But the toString warning revealed that it loses the "injected" %s specifier; that would be witnessed only if one of the rare "edge case" warnings happened to be emitted. Now it does not discard on warnings, only on hard errors.

Fixes #23693

@som-snytt
Copy link
Contributor Author

som-snytt commented Aug 8, 2025

Note to self: it would have been easier to see what was going on if FormatInterpolatorTransform were inlined in StringInterpolatorOpt#transformF. It's confusing that Transform.checked dispatches to FormatChecker#checked. I see the components were confusing before the refactor or forward port, but it could be simpler; that is, extra layers harms local reasoning. It's also nice when names are different.

Edit: went ahead and inlined that code. The other suboptimal thing is "string is empty" means "error".

@som-snytt som-snytt marked this pull request as ready for review August 8, 2025 23:58
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.

String iterpolation warnings should have a error id
1 participant