Allow Generate return symbolic variables as input - #475
Merged
Conversation
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.
Support Symbolic Variables in Command Inputs
Motivation
Commands often need to reference outputs from previous commands (e.g., looking up a user ID that was returned by a prior registration). Previously,
Var<T>could only be used as command outputs. Using them as inputs was not supported, making it difficult when commands need to randomly select from collections of symbolic references stored in the state, especially when shrinking can leave variables unbound.The Solution
Commands can now accept
Var<T>as input parameters:Var<T>when picking from state (e.g., randomly selecting fromList<Var<int>>)Key Changes
Resolve,ResolveOr, andTryResolvemethods for safe variable resolutionVar.mapto extract fields from command outputsRequiremethod receives environment to verify variable resolvability, preventing crashes during shrinkingExample
Commands can now naturally work with symbolic variables as inputs, while
Requireensures safe shrinking by skipping commands when referenced variables are unbound.