Let premise introduction pass #213
Draft
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.
It probably is a good time to make use of the let premise in efforts to make function definitions more translatable.
This pass goes through all list of premises, and if there is a LHS that has a variable that has not been declared before, then it introduces a let premise.
Due to this approach, this pass relies on the ordering of the premises. Perhaps there is a way to remove this restriction but for now this naive approach should work fine.
Valid LHS are:
VarE, StrE (records), CaseE, IterE (probably should only allow identity iteration), TupE
In the validator, there are some RHS that need to be inferred, but some expressions are not possible to have there type inferred.
So, the RHS not allowed are:
OptE, StrE
For the most part, this works well. However due to some of the restrictions above, (and uncaseE appearing in unfortunate locations) it sometimes just does not introduce the let premise.
Example from Wasm 3.0:
to
Based off #198 so need to merge that one first.