Improve the arity error message for destructuring let - #22314
Open
MavenRain wants to merge 1 commit into
Open
Conversation
"Destructing let on this type expects 2 variables." now names the destructured term and its type, and reports how many variables were given: Destructing let on term "p" of type "point2d" expects 2 variables, but 3 were given. Following the review guidance on the earlier attempt rocq-prover#7943, the error is plumbed as a proper Pretype_errors constructor (LetTupleArity) rendered in Himsg, instead of a raw user_err inside the pretyper. Fixes rocq-prover#7833 Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
MavenRain
force-pushed
the
7833-lettuple-arity-error
branch
from
July 27, 2026 09:34
f01ee09 to
db3d1ea
Compare
Contributor
|
I'm not sure we want to print the full term and type. They can be arbitrarily large. Also we have the error location pointing at the term so printing it seems redundant. (where the full type would be (but I have a strong bias towards brevity, so maybe the average user would benefit from the full term & type? IDK) |
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.
Fixes / closes #7833
Explanation
The arity error for a destructuring
letused to be a bareuser_errin thepretyper:
It now names the destructured term and its type, and reports the number of
variables actually given:
As requested in the review of the earlier attempt #7943, no
Printercall ismade inside pretyping: the error is a new
Pretype_errors.pretype_errorconstructor (
LetTupleArity, carrying the judgment of the destructured termplus the expected and given variable counts) raised through a new
error_lettuple_arityhelper and rendered inHimsg, mirroring theneighboring
CaseNotInductive/NumberBranchesplumbing.API note:
Pretype_errors.pretype_errorgains theLetTupleArityconstructor, so external plugin code matching exhaustively on
pretype_errorneeds a new arm. In-tree code needed no change besidesHimsg.The new output test covers both plural renderings in each position
("expects 1 variable" / "expects 2 variables", "1 was given" / "3 were
given").
test-suite/output/bug_7833.v).Drafted with AI assistance; the change and its verification (full build,
output test-suite, mutation check on the new test) were reviewed and run
locally by me.