[compiler] Add format string validation for assert macros#18533
Merged
[compiler] Add format string validation for assert macros#18533
Conversation
d3679e2 to
d0a0c00
Compare
vineethk
reviewed
Feb 2, 2026
d0a0c00 to
c587d8a
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
c587d8a to
fe82dd6
Compare
vineethk
approved these changes
Feb 5, 2026
vineethk
approved these changes
Feb 5, 2026
junxzm1990
reviewed
Feb 5, 2026
junxzm1990
approved these changes
Feb 5, 2026
fe82dd6 to
c7033cf
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c7033cf to
3661b31
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3661b31 to
60f0e99
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
60f0e99 to
3dfb957
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
✅ Forge suite
|
Contributor
✅ Forge suite
|
Contributor
✅ Forge suite
|
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.
Description
Follow up to #18412 (comment)
This commit adds compile-time validation for format strings used in
assert!,assert_eq!, andassert_ne!macros in the Move compiler. Th compiler now detects mismatched braces, invalid placeholders, and ensures the number of{}placeholders matches the number of arguments provided. This prevents runtime errors by catching issues early.How Has This Been Tested?
Added new tests for invalid forms.
Key Areas to Review
Type of Change
Which Components or Systems Does This Change Impact?
Checklist
Note
Medium Risk
Changes Move compiler macro expansion to reject previously-accepted
assert!/assert_eq!/assert_ne!format strings (brace/placeholder/arg-count issues), which may surface new compile errors for existing code.Overview
Compiler behavior change:
assert!,assert_eq!, andassert_ne!now validate format strings at expansion time, detecting unmatched/invalid braces, counting{}placeholders (with{{/}}escaping), and enforcing that placeholder count matches the number of provided format arguments.Tests: Extends macro tests with an escaped-brace formatting case and adds new negative tests/expected diagnostics for malformed format strings and argument-count mismatches.
Written by Cursor Bugbot for commit 3dfb957. This will update automatically on new commits. Configure here.