-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add branching model to constraint builder #430
Merged
Merged
Conversation
This file contains 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
JSAbrahams
force-pushed
the
propagate-type-to-vardef
branch
from
January 5, 2023 15:50
16fde9e
to
04c50fd
Compare
JSAbrahams
force-pushed
the
propagate-type-to-vardef
branch
from
January 5, 2023 16:19
04c50fd
to
3545748
Compare
JSAbrahams
changed the title
Propagate ast type to definitions in match, if
Branching model in constraint builder
Jan 5, 2023
Codecov Report
@@ Coverage Diff @@
## develop #430 +/- ##
===========================================
+ Coverage 88.34% 88.59% +0.25%
===========================================
Files 110 110
Lines 11997 11956 -41
===========================================
- Hits 10599 10593 -6
+ Misses 1398 1363 -35
|
Well the unit tests now pass. Predictably, some integration tests don't. Mostly problems with: - Catching exceptions - Some issues with shadowing
JSAbrahams
changed the title
Branching model in constraint builder
Update branching in constraint builder
Jan 5, 2023
Need to fix now how variable mapping and branching interact.
Still some issues in regard to shadow logic. Remove Environment union and intersection. This is a language feature we actually don't want.
JSAbrahams
commented
Jan 6, 2023
Use new system to revert behaviour of collection.
I don't think we need the Expect::Collection construct at all. We only need to know whether something defines __iter__(). We can use an access constraint for that. Will add in future. - Ignore types because it uses type aliases - Revert some behaviour in definition check. Double check if this isn't due to change in behaviour in generate stage.
This was
linked to
issues
Jan 8, 2023
JSAbrahams
changed the title
Update branching in constraint builder
Add branching model in constraint builder
Jan 8, 2023
JSAbrahams
changed the title
Add branching model in constraint builder
Add branching model to constraint builder
Jan 8, 2023
Merged
JSAbrahams
added a commit
that referenced
this pull request
Jan 21, 2023
* Propagate ast type to definitions in match, if * Add branch points to constraint builder * Only check raises caught if in function * Move AST map logic to expected * Allow change order variable mapping * Remove unused default Constraints * Environment mapping takes precedence in Expect map * Fix constraint generation in lookup * Add destruction of variables in environment * Preserve self mapping in env between classes
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.
Relevant issues
Expect::Collection
construct #437Summary
Another addition to the constraint builder, similar to #416 .
This time, we implement a new branching model which allows us to now finally properly check converging paths:
It will copy over all constraints from the previous set, up to the branch point.
We now only create branches for:
This means that we don't unnecessarily create new sets when entering classes, for loops, while loops, etc.
Only when we have diverging execution paths.
Shadowing of variables is now no longer maintained partially by different sets, but instead by shadowing of variables in:
This means that even if a mapping exists in the global scope, if the variable does not exist in the local environment at all then we still get an error.
This same logic is also used when we recursively substitute identifiers within
AST
s.self
from the environment with the global mapping ofself
when exiting a class..As a result of this refactor, we also moved some var mapping logic to the builder to make it easier to change.
This means that
Expected::from(AST)
has been greatly simplified.In fact, there was no reason for it to return a result now.
Destruction of variables
Due to the change in behavior, we had to add destruction variables in the environment in case we are no longer allowed to access them:
with <resource> as <alias>
, where the resource itself is now no longer accessible.In other locations where we use a type alias we should also destruct variables.
For instance, if in
match
if we in future allow type aliases to be used there.Propagate assigns
If we assign to a variable ,that variable has a type.
Normally we annotate this with a type.
We now also do this even when we propagate an assign into a match or if:
Example with if:
Generates:
Before: