Improve error handling and panic messages in Rust evaluator#1867
Open
arnaudgelas wants to merge 2 commits intoinformalsystems:mainfrom
Open
Improve error handling and panic messages in Rust evaluator#1867arnaudgelas wants to merge 2 commits intoinformalsystems:mainfrom
arnaudgelas wants to merge 2 commits intoinformalsystems:mainfrom
Conversation
This commit addresses multiple panic sites in the Rust evaluator to improve debuggability and provide safer alternatives for error handling. **value.rs - New safe accessor methods:** - Add `try_as_int()`, `try_as_bool()`, `try_as_str()` returning `Result<T, QuintError>` - Add `try_as_map()`, `try_as_list()`, `try_as_record_map()`, `try_as_variant()` - Add `type_name()` helper for generating informative error messages - These provide safe alternatives for callers that need to handle type mismatches gracefully rather than panicking **value.rs - Improved panic messages:** - All `as_*` methods now include the actual type name in panic messages (e.g., "Expected integer, got boolean" instead of "Expected integer") - `cardinality()` and `contains()` panics now show type names - Lambda hash/comparison panics now explain that lambdas are not hashable in Quint **builtins.rs - Convert panics to runtime errors:** - Unknown lazy/eager operators now return QNT500 error instead of panicking - This allows better error recovery and more informative error messages - `getOnlyElement` unwrap replaced with documented expect The existing `as_*` methods are retained for internal use where type correctness is guaranteed by the type checker, but now provide better debugging information if assumptions are violated. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
This commit addresses multiple panic sites in the Rust evaluator to improve debuggability and provide safer alternatives for error handling.
value.rs - New safe accessor methods:
try_as_int(),try_as_bool(),try_as_str()returningResult<T, QuintError>try_as_map(),try_as_list(),try_as_record_map(),try_as_variant()type_name()helper for generating informative error messagesvalue.rs - Improved panic messages:
as_*methods now include the actual type name in panic messages (e.g., "Expected integer, got boolean" instead of "Expected integer")cardinality()andcontains()panics now show type namesbuiltins.rs - Convert panics to runtime errors:
getOnlyElementunwrap replaced with documented expectThe existing
as_*methods are retained for internal use where type correctness is guaranteed by the type checker, but now provide better debugging information if assumptions are violated.(including screenshots is helpful)
CHANGELOG.mdfor any new functionality