Repository navigation
Typed errors for label conversion, unalias and verify - #18
Merged
Merged
Conversation
The remaining bullet of #6: the conversion helpers returned `Result<_, String>`, so callers had to match on message text. - `LabelError` for `try_into_bdd`, `try_into_prop` and `try_into_hoa_expression`: `ApOutOfRange { ap, count }` and `UnresolvedAlias(name)`. - `AliasError` for `unalias`: `Undefined(name)` and `Cyclic(name)`. - `VerifyError` per violation and `VerifyErrors` (derefs to `[VerifyError]`) for `verify`. All of them implement `std::error::Error`. `unalias` now walks the aliases in file order, so the alias named in a cycle no longer depends on `HashMap` iteration order. Messages are unchanged apart from lower-casing and the state-count wording.
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.
Closes the remaining bullet of #6: the label conversion helpers returned
Result<_, String>, so callers had to inspect message text.FromHoaError/ValidationErroralready implementstd::error::Error(0.4.0); this finishes the API.New types (
src/error.rs)All implement
Displayandstd::error::Error, so they work as#[source]/#[from]fields downstream.VerifyErrorskeepsverify's existing "report everything at once" behaviour;VerifyErroris the single violation to match on.Breaking changes
AbstractLabelExpression::try_into_bddResult<Bdd, String>Result<Bdd, LabelError>AbstractLabelExpression::try_into_propResult<HoaExpression, String>Result<HoaExpression, LabelError>LabelExpression::try_into_hoa_expressionResult<HoaExpression, String>Result<HoaExpression, LabelError>HoaRepresentation::unaliasResult<(), String>Result<(), AliasError>HoaRepresentation::verifyResult<(), String>Result<(), VerifyErrors>Messages keep their old text apart from lower-casing and the state-count wording (
`States:` says 3 but the body defines 4).Behaviour fix
unaliasbuilt its substitution map by iterating aHashMap, so for a cyclic alias the reported name changed between runs. It now walksalias_iter(), i.e. file order, soAlias: @x @y/Alias: @y !@x | 0always reportsCyclic("x"). This matters now that the name is part of a typed, matchable error.Tests
55 (was 53):
unalias_rejects_undefined_and_cyclic_aliasesandverify_reports_duplicate_statesnow assert exact variants, newverify_reports_state_count_mismatch,label::tests::unresolved_alias_is_an_error, anderror::tests::conversion_errors_are_std_errorswhich boxes each type intoBox<dyn std::error::Error>../scripts/checkpasses: fmt, clippy-D warnings, rustdoc-D warnings, benches compile, all tests. No benchmark-relevant code paths changed (error construction only), so no before/after table.Closes #6.