Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow can and try functions to handle more unknown
The `can` and `try` functions can return more precise results in some cases. Rather than try to inspect the expressions for any unknown values, rely on the evaluation result to be correct or error and base the decision on the evaluated values and errors. A fundamental requirement for the `try` and `can` functions is that the value and types remain consistent as argument values are refined. This can be done provided we hold these conditions regarding unknowns to be true: - An evaluation error can never be fixed by an unknown value becoming known. - An entirely known value from an expression cannot later become unknown as values are refined. - A expression result must always have a consistent type and value. only allowing the refinement of unknown values and types. - An expression result cannot be conditionally based on the "known-ness" of a value (which is really the premise for all previous statements). As long as those conditions remain true, the result of the `try` argument's evaluation can be trusted, and we don't need to bail out early at any sign of an unknown in the argument expressions. While the evaluation result of each argument can be trusted in isolation however, the fact that different types and values can be returned by `try` means we need to convert the return to the most generic value possible to prevent inconsistent results ourself (adhering to the 3rd condition above). That means anything which is not entirely known must be converted to a dynamic value. Evan more refinement might still be possible in the future if all arguments are evaluated and compared for compatibility, but care needs to be taken to prevent changing known values within collections from different arguments even when types are identical.
- Loading branch information