Repository navigation
Report an error for a format at the end of the string - #15
Merged
Merged
Conversation
DIGarnier
force-pushed
the
fix-trailing-format
branch
3 times, most recently
from
November 12, 2026 23:10
6cc5a36 to
45d6cc9
Compare
bn-d
reviewed
Nov 12, 2026
| let valid_test1 _ = | ||
| assert_expands | ||
| ~expected:{|let _ = "Sale: 50% off today"|} | ||
| {|let _ = [%string "Sale: 50%% off today"]|} |
A format specifier with nothing after it to apply to, such as [%string "%d"] or [%string "50% off"], was dropped without any message, cutting off the rest of the string. The same mistake in the middle of a string already reports "Format is not followed by variable/expression"; report it at the end of the string as well. Add tests that run the rewriter on snippets and check its errors. Signed-off-by: David Garnier <dgarnier4@bloomberg.net>
Require OCaml >= 4.11.0 as the published 1.1.0 package does. The bound was raised in opam-repository after the lower-bounds CI jobs failed on OCaml 4.08 and 4.09, where older sedlex versions do not provide a compatible ppx driver: ocaml/opam-repository#28114 (comment) Also add ounit as a test dependency and run the tests with {with-test}. Signed-off-by: David Garnier <dgarnier4@bloomberg.net>
Add CHANGES.md entries for 1.2.0 and the earlier 1.0.1 and 1.1.0 releases. Signed-off-by: David Garnier <dgarnier4@bloomberg.net>
Build and test on Linux with OCaml 4.11, 4.14 and 5, and on macOS with OCaml 5, and check formatting with ocamlformat 0.27.0. Actions are pinned to commit SHAs and kept up to date by Dependabot. Signed-off-by: David Garnier <dgarnier4@bloomberg.net>
DIGarnier
force-pushed
the
fix-trailing-format
branch
from
November 12, 2026 23:20
45d6cc9 to
b70dcfe
Compare
Signed-off-by: David Garnier <dgarnier4@bloomberg.net>
ubuntu-latest now ships GCC 15, which compiles C as C23 by default, and the OCaml 4.11 runtime does not build under C23. Signed-off-by: David Garnier <dgarnier4@bloomberg.net>
DIGarnier
marked this pull request as ready for review
November 12, 2026 23:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A format specifier with nothing after it to apply to was dropped without
any message, cutting off the rest of the string:
[%string "%d"]produced""[%string "Sale: 50% off today"]produced"Sale: 50"The same mistake in the middle of a string already reports
"Format is not followed by variable/expression". This reports it at the
end of the string as well, pointing at the
%. Use%%for a literalpercent sign.
Strings that previously compiled with a trailing bare
%will now failto compile;
CHANGES.mdhas a note under Unreleased.Tests: added
test/ppx_string_interpolation_errors_test.ml, which runsthe rewriter on source snippets and checks the reported error.
Also in this PR, as separate commits:
published 1.1.0 does (raised there after the lower-bounds CI failed on
OCaml 4.08 and 4.09 because of sedlex, see
Package ppx_string_interpolation.1.1.0 ocaml/opam-repository#28114 (comment)),
add
ounitas a test dependency and run the tests with{with-test}.CHANGES.mdentries for 1.2.0, plus themissing 1.0.1 and 1.1.0 entries.